User Tools

Site Tools


en:readbyte

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:readbyte [2016/08/12 21:28]
admin
en:readbyte [2020/02/28 10:46]
Line 1: Line 1:
-===== ReadByte (Function) ===== 
-==== Format ==== 
-**readbyte**\\ 
-**readbyte** ( )\\ 
-**readbyte** ( [[integerexpressions|open_file_number]] ) 
- 
-returns [[integerexpressions|integer_expression]] 
- 
-==== Description ==== 
-Reads and returns the next byte (8 bits) as a number 0-255 from an open file.  If the file number is not specified file number zero (0) will be used. 
-\\ 
-File should be opened with the [[open|Openb]] statement so that ASCII CR/LF translation does not happen. 
-\\ 
-In you are reading a serial port opened with [[OpenSerial|OpenSerial]] no translation will happen.  Additionally a -1 will be returned if there was no data in the receive buffer. 
- 
-==== Example ==== 
- 
-<code> 
-cls 
-f$ = "binary.dat" 
- 
-print "new file" 
-openb f$ 
-reset 
-for t = 1 to 20 
-   n = r() 
-   print n+" "; 
-   writebyte n 
-next t 
-print 
-close 
- 
-print "open and read" 
-openb f$ 
-while not eof 
-   print readbyte()+" "; 
-end while 
-print 
- 
-print "position to 10 and read" 
-seek 10 
-while not eof 
-   print readbyte()+" "; 
-end while 
-print 
- 
-close 
- 
-end 
- 
-function r() 
-   r = int(rand*256) 
-end function 
-</code> 
-will display something like 
-<code> 
-new file 
-181 163 155 23 46 93 122 212 178 225 1 62 113 130 202 52 185 51 37 165  
-open and read 
-181 163 155 23 46 93 122 212 178 225 1 62 113 130 202 52 185 51 37 165  
-position to 10 and read 
-1 62 113 130 202 52 185 51 37 165  
-</code> 
- 
- 
-==== See Also ==== 
-{{page>en:start#File and Serial Port Input/Output&noheader}} 
- 
-==== History ====  
-|1.1.4.0|Added Serial Port| 
  
en/readbyte.txt ยท Last modified: 2020/02/28 10:46 (external edit)