| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <html>
- <head>
- <title>Blitz3D Docs</title>
- <link rel=stylesheet href=../css/commands.css type=text/css>
- </head>
- <body>
- <h1>ReadBytes bank,file/stream,offset,count</h1>
- <h1>Parameters</h1>
- <table>
- <tr>
- <td>
- bank = variable containing handle to valid bank
<br />
- file/stream = file handle of previously opened file or stream
<br />
- offset = offset in bytes to write the value
<br />
- count = how many bytes to write from the offset
- </td>
- </tr>
- </table>
- <h1>Description</h1>
- <table>
- <tr>
- <td>
- You can read the contents of a disk file (or stream) to a memory bank using this command.
<br />
-
<br />
- Note: The file handle must be opened with OpenFile or OpenTCPStream and subsequently closed with CloseFile or CloseTCPStream after the reading operations are complete.
<br />
-
<br />
- Return how many bytes successfully read from a stream.
<br />
-
<br />
- Streams can only be used in Blitz Basic v1.52 or greater.
- <br>
- <br>
- See also: <a class=small href=WriteBytes.htm>WriteBytes</a>.
- </td>
- </tr>
- </table>
- <h1><a href=../2d_examples/ReadBytes.bb>Example</a></h1>
- <table>
- <tr>
- <td>
- ; Read/WriteBytes Commands Example
<br />
-
<br />
- ; Create a 50 byte memory bank
<br />
- bnkTest=CreateBank(500)
<br />
-
<br />
- ; Let's fill the bank with random data
<br />
- For t = 1 To 50
<br />
-
<br />
- PokeByte bnkTest,t,Rnd(255)
<br />
-
<br />
- Next
<br />
-
<br />
- ; Open a file to write to
<br />
- fileBank=WriteFile("test.bnk")
<br />
- ; Write the bank to the file
<br />
- WriteBytes bnkTest,fileBank,0,50
<br />
- ; Close it
<br />
- CloseFile fileBank
<br />
-
<br />
- ; Free the bank
<br />
- FreeBank bnkTest
<br />
-
<br />
- ; Make a new one
<br />
- bnkTest=CreateBank(500)
<br />
-
<br />
- ; Open the file to read from
<br />
- fileBank=OpenFile("test.bnk")
<br />
- ; Write the bank to the file
<br />
- ReadBytes bnkTest,fileBank,0,50
<br />
- ; Close it
<br />
- CloseFile fileBank
<br />
-
<br />
- ; Write back the results!
<br />
- For t = 1 To 50
<br />
-
<br />
- Print PeekByte (bnkTest,t)
<br />
-
<br />
- Next
- </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=ReadBytes&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
- </html>
|