| stream - a file stream opened for reading, or a TCP stream |
|
Reads a floating point value from a file or stream. A float occupies 4 bytes and comes back exactly as WriteFloat stored it - positions, angles, volumes and anything else with a fractional part travel through files and network streams this way. Reading past the end of the file is not an error; you simply get 0.0, so use Eof to know when the real data has run out. See also: WriteFloat, ReadInt, ReadString, Eof. |
; ReadFloat Example
; -----------------
; Save some floats so there is something to read
file=WriteFile("demo_floats.dat")
WriteFloat file,10.5
WriteFloat file,-0.125
WriteFloat file,365.25
CloseFile file
; ReadFloat reads a 4-byte single-precision float
file=ReadFile("demo_floats.dat")
a#=ReadFloat(file)
b#=ReadFloat(file)
c#=ReadFloat(file)
CloseFile file
Print "Floats read from demo_floats.dat:"
Print " "+a
Print " "+b
Print " "+c
; Clean up the demo file
DeleteFile "demo_floats.dat"
Print "Deleted demo_floats.dat"
Print ""
Print "Press any key to close the example"
WaitKey
End