Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Screen Capture
Message
From
07/11/2000 17:53:21
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00438986
Message ID:
00439062
Views:
20
*-- The following function converts a long integer to an ASCII
>*-- character representation of the passed value in low-high format.
>******************
>Function LongToStr
>******************
>* Passed : 32-bit non-negative numeric value (lnLongval)
>* Returns : ascii character representation of passed value in low-high
>* format (lcRetstr)
>* Example :
>* m.long = "999999"
>* m.longstr = long2str(m.long)
>
>Parameters lnLongval
>Private i, lcRetstr
>lcRetstr = ""
>
>For i = 24 TO 0 STEP -8
> lcRetstr = CHR(INT(lnLongval/(2^i))) + lcRetstr
> lnLongval = MOD(lnLongval, (2^i))
>Next
>
>Return lcRetstr
>

&& Could I suggest:

FUNCTION NumToLong
LPARAMETERS tnLongValue
LOCAL cRetValue
DECLARE RtlMoveMemory IN WIN32API AS RtlCopyMem ;
STRING @ Dest, ;
INTEGER @ Source; ;
INTEGER nLength
cRetVal = SPACE(4)
=RtlCopyMem(@cRetVal, BITOR(tnLongValue,0), 4)
RETURN cRetVal

>
>
>*-- The following function converts a string in low-high format to a
>*-- long integer.
>******************
>Function StrToLong
>******************
>* Passed: 4-byte character string (lcLongstr) in low-high ASCII format
>* Returns: long integer value
>* Example:
>* m.longstr = "1111"
>* m.longval = str2long(m.longstr)
>
>Parameters lcLongstr
>Private i, lnRetval
>
>lnRetval = 0
>For i = 0 TO 24 STEP 8
> lnRetval = lnRetval + (ASC(lcLongstr) * (2^i))
> lcLongstr = RIGHT(lcLongstr, LEN(lcLongstr) - 1)
>Next
>
>Return lnRetval
>*-- Code ends here

&& and:

FUNCTION LongToNum
LPARAMETERS tcLongValue
LOCAL nRetValue
DECLARE RtlMoveMemory IN WIN32API AS RtlCopyMem ;
INTEGER @ Dest, ;
STRING @ Source; ;
INTEGER nLength
nRetVal = 0
=RtlCopyMem(@nRetVal, tcLongValue, 4)
RETURN nRetVal

>
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform