Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getfreediskspaceex
Message
From
15/07/2020 08:56:30
 
 
To
04/04/2002 08:59:20
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00640820
Message ID:
01675184
Views:
89
>FUNCTION Str2num
>LPARAMETERS tcStr,tnLen
>local lnRetVal
>lnRetVal = 0
>FOR ix=1 TO tnLen
> lnRetVal = lnRetVal + ASC(SUBSTR(tcStr,ix))*(256^(ix-1))
>endfor
>RETURN TRANSFORM(lnRetVal,'999,999,999,999,999')Cetin

This function can also be re-written as:
FUNCTION Str2num
LPARAMETERS tcStr, tnLen
LOCAL lnI, lnReturn
    lnReturn = 0
    FOR lnI = tnLen TO 1 STEP -1
        lnReturn = (lnReturn * 256) + ASC(SUBSTR(tcStr, lnI))
    NEXT
    RETURN TRANSFORM(lnReturn, '999,999,999,999,999')
It's a little less expensive (3.31 seconds compared to 4.13 seconds on 1M iterations), though it hardly matters.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform