*-- 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
>