User Tools

Site Tools


pt:readbyte

Differences

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

Link to this comparison view

pt:readbyte [2016/01/01 22:48]
pt:readbyte [2020/02/28 10:46] (current)
Line 1: Line 1:
 +===== ReadByte =====
 +==== Formato ====
 +**readbyte**\\
 +**readbyte**()\\
 +**readbyte**(//filenumber//)
 +==== Descrição ====
 +Lê e devolve o próximo byte (8 bits) como um número de 0 a 255 de um ficheiro aberto.  Se o número de ficheiro não for especificado então o zero (0) será assumido.
 +\\
 +O ficheiro deve ser aberto com a instrução [[open|Openb]] para que a tradução ASCII CR/LF não ocorra.
 +
 +==== Exemplo ====
 +
 +<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>
 +mostará qualquer coisa como...
 +<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>
 +
 +
 +
 +==== Também ====
 +[[close|Close]], [[eof|Eof]], [[open|Open]], [[open|Openb]], [[readbyte|ReadByte]], [[readline|Readline]], [[reset|Reset]], [[write|Write]], [[writebyte|Writebyte]], [[writeline|Writeline]], [[exists|Exists]], [[seek|Seek]], [[size|Size]]
  
pt/readbyte.txt · Last modified: 2020/02/28 10:46 (external edit)