| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <html>
- <head>
- <title>Blitz3D Docs</title>
- <link rel=stylesheet href=../css/commands.css type=text/css>
- </head>
- <body>
- <h1>ReadFloat (filehandle/stream)</h1>
- <h1>Parameters</h1>
- <table>
- <tr>
- <td>
- filehandle/stream = a valid variable set with the OpenFile, ReadFile command, or OpenTCPStream (v1.52+) The value returned is a floating point number.
- </td>
- </tr>
- </table>
- <h1>Description</h1>
- <table>
- <tr>
- <td>
- Once you've opened a disk file (or stream) for reading, use this command to read a single floating point number from the file. Note, each value written uses 4 bytes of space. Reading beyond the end of file does not result in an error, but each value read will be zero.
<br />
-
<br />
- Streams can only be used in Blitz Basic v1.52 or greater.
- </td>
- </tr>
- </table>
- <h1><a href=../2d_examples/ReadFloat.bb>Example</a></h1>
- <table>
- <tr>
- <td>
- ; Reading and writing a file using ReadFloat and WriteFloat functions
<br />
-
<br />
- ; Initialise some variables for the example
<br />
- Num1# = 10.5 ; store 10.5
<br />
- Num2# = 365.25 ; store 365.25
<br />
- Num3# = 32767.123 ; 32767.123 is the largest positive Short Integer Value in BlitzBasic )
<br />
- Num4# = -32768.123 ; -32768.123 the largest negative Short Integer Value in BlitzBasic )
<br />
-
<br />
- ; Open a file to write to
<br />
- fileout = WriteFile("mydata.dat")
<br />
-
<br />
- ; Write the information to the file
<br />
- WriteFloat( fileout, Num1 )
<br />
- WriteFloat( fileout, Num2 )
<br />
- WriteFloat( fileout, Num3 )
<br />
- WriteFloat( fileout, Num4 )
<br />
-
<br />
- ; Close the file
<br />
- CloseFile( fileout )
<br />
-
<br />
- ; Open the file to Read
<br />
- filein = ReadFile("mydata.dat")
<br />
-
<br />
- Read1# = ReadFloat( filein )
<br />
- Read2# = ReadFloat( filein )
<br />
- Read3# = ReadFloat( filein )
<br />
- Read4# = ReadFloat( filein )
<br />
-
<br />
- ; Close the file once reading is finished
<br />
- CloseFile( filein )
<br />
-
<br />
- Print "Floating Point Data Read From File - mydata.dat "
<br />
- Print Read1
<br />
- Print Read2
<br />
- Print Read3
<br />
- Print Read4
<br />
-
<br />
- WaitKey()
<br />
- </td>
- </tr>
- </table>
- <br>
- <a target=_top href=../index.htm>Index</a><br>
- <br>
- Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=ReadFloat&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
- </html>
|