Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP And Float data type
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00258195
Message ID:
00258454
Views:
13
>Wow, you are good !! Thanks a lot. And now how do i convert the numeric value 1.9988 back to the string Chr(174)+chr(216)+chr(255)+chr(63)
>

The inverse function, of course!
FUNCTION NumToSingle
LPARAMETER tnNumber
DECLARE RtlMoveMemory IN WIN32API AS RtlCopyDbl ;
	STRING @DestString, ;
	SINGLE @pVoidSource, ;
	INTEGER nLength
LOCAL lcString
lcString = SPACE(4)
=RtlCopyDbl(@lcString, tnNumber,4)
RETURN lcString
>A million tanks.
>
>>That's a parameter type SINGLE, assuming that it's IEEE 754 compliant. As I remember, there's a bug related to the SINGLE parameter return value; Christof Lange and I have proven out the following code to convert a single contained in a VFP string (usually a part of a structure) back to a VFP numeric in straightforward fashion using RtlMoveMemory():
>>
>>
FUNCTION ConvertSINGLEToVFPNum
>>LPARAMETER tcSingle
>>* tcSingle is a 4 byte representation contained in a VFP string
>>DECLARE RtlMoveMemory IN WIN32API AS RtlCopyDbl ;
>>	SINGLE @DestNumeric, ;
>>	STRING @pVoidSource, ;
>>	INTEGER nLength
>>LOCAL lnNum
>>lnNum = 0.000000000000000
>>=RtlCopyDbl(@lnNum, tcSingle, 4)
>>RETURN lnNum
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
Reply
Map
View

Click here to load this message in the networking platform