| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <html>
- <head>
- <title>Blitz3D Docs</title>
- <link rel=stylesheet href=../css/commands.css type=text/css>
- </head>
- <body>
- <h1>ReadInt (filehandle/stream)</h1>
- <h1>Parameters</h1>
- <table>
- <tr>
- <td>
- filehandle/stream = a valid variable set with the OpenFile, ReadFile command, or OpenTCPStream (v1.52+)
<br />
- The value returned is an integer in the range -2147483648 to 2147483647
- </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 integer value from the file. Note, each value written uses 4 bytes of space and is written least significant byte first. 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/ReadInt.bb>Example</a></h1>
- <table>
- <tr>
- <td>
- ; Reading and writing a file using ReadInt and WriteInt functions
<br />
-
<br />
- ; Initialise some variables for the example
<br />
- Int1% = 10 ; store 10
<br />
- Int2% = 365 ; store 365
<br />
- Int3% = 2147483647 ; store 2147483647 the largest positive Integer Value in BlitzBasic )
<br />
- Int4% = - 2147483648 ; store -2147483648 the largest negative 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 />
- WriteInt( fileout, Int1 )
<br />
- WriteInt( fileout, Int2 )
<br />
- WriteInt( fileout, Int3 )
<br />
- WriteInt( fileout, Int4 )
<br />
-
<br />
- ; Close the file
<br />
- CloseFile( fileout )
<br />
-
<br />
- ; Open the file to Read
<br />
- filein = ReadFile("mydata.dat")
<br />
-
<br />
- Read1 = ReadInt( filein )
<br />
- Read2 = ReadInt( filein )
<br />
- Read3 = ReadInt( filein )
<br />
- Read4 = ReadInt( filein )
<br />
-
<br />
- ; Close the file once reading is finished
<br />
- CloseFile( filein )
<br />
-
<br />
- Print "Integer 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=ReadInt&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
- </html>
|