This shows you the differences between two versions of the page.
en:readbyte [2016/08/12 12:51] admin |
en:readbyte [2020/02/28 10:46] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== ReadByte (Function) ===== | ||
- | ==== Format ==== | ||
- | **readbyte**\\ | ||
- | **readbyte** ( )\\ | ||
- | **readbyte** ( // | ||
- | |||
- | 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. | ||
- | |||
- | ==== Example ==== | ||
- | |||
- | < | ||
- | cls | ||
- | f$ = " | ||
- | |||
- | print "new file" | ||
- | openb f$ | ||
- | reset | ||
- | for t = 1 to 20 | ||
- | n = r() | ||
- | print n+" "; | ||
- | | ||
- | next t | ||
- | |||
- | close | ||
- | |||
- | print "open and read" | ||
- | openb f$ | ||
- | while not eof | ||
- | print readbyte()+" | ||
- | end while | ||
- | |||
- | |||
- | print " | ||
- | seek 10 | ||
- | while not eof | ||
- | print readbyte()+" | ||
- | end while | ||
- | |||
- | |||
- | close | ||
- | |||
- | end | ||
- | |||
- | function r() | ||
- | r = int(rand*256) | ||
- | end function | ||
- | </ | ||
- | will display something like | ||
- | < | ||
- | 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 | ||
- | </ | ||
- | |||
- | |||
- | ==== See Also ==== | ||
- | {{page> | ||
- | |||
- | ==== History ==== | ||
- | |1.1.4.0|Added Serial Port| | ||