Reading binary data files

I'm not sure about the floating point, but the two byte integer can be be

calculated like this:

S = fRead(f, 2)

N = Asc(S) + 256 * Asc(SubStr(S,2))

(This works for positive integers.)

Here is a generic solution for an integer of any length (where F is a file

and IntSize is the number of bytes in the integer):

Function ReadInt(F, IntSize)

local S, i, Result

S = FRead(F, IntSize)

Result = 0

For i =IntSize to 1 step -1

Result = Result * 256 + Asc(SubStr(S,i))

EndFor

If Result >= 2 ^ (IntSize * 8 - 1) && Is the number negative

Result = Result - 2 ^ (IntSize * 8)

EndIf

Return Result

--

Michael Schuldenfrei