Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reading Float values from binary files
Message
From
19/05/2002 08:37:35
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00658650
Message ID:
00658654
Views:
15
>I have a question about processing binary file with Foxpro.
>Foxpro provides some functions, like fread(), for reading
>binary files. However, it seems that these functions assume
>the input data as strings. So if the data input from the
>binary file is actually integers or float numbers, how can I
>do?

You'll have to provide functions for that. Reading integers should be easy. Here is an example (assuming little endian integers):
FUNCTION GetInt16
LPARAMETER nFile, nOffset
LOCAL lnHigh, lnLow

IF PCOUNT()=2
  FSEEK(nFile,nOffset,0)
ENDIF
lnLow = ASC(FREAD(nFile,1))
lnHigh = ASC(FREAD(nFile,1))

RETURN lnHigh*0x100+lnLow
32 bits and signed integers handling can go from here.

There are many float numbers formats, it will not be an easy task unless you find a suitable function for the format you must take care of.
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform