This shows you the differences between two versions of the page.
pt:readbyte [2016/01/01 22:48] |
pt:readbyte [2020/02/28 10:46] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== ReadByte ===== | ||
+ | ==== Formato ==== | ||
+ | **readbyte**\\ | ||
+ | **readbyte**()\\ | ||
+ | **readbyte**(// | ||
+ | ==== Descrição ==== | ||
+ | Lê e devolve o próximo byte (8 bits) como um número de 0 a 255 de um ficheiro aberto. | ||
+ | \\ | ||
+ | O ficheiro deve ser aberto com a instrução [[open|Openb]] para que a tradução ASCII CR/LF não ocorra. | ||
+ | |||
+ | ==== Exemplo ==== | ||
+ | |||
+ | < | ||
+ | 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 | ||
+ | </ | ||
+ | mostará qualquer coisa como... | ||
+ | < | ||
+ | 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 | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ==== Também ==== | ||
+ | [[close|Close]], | ||