User Tools

Site Tools


Action disabled: register
pt:readbyte

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 Openb para que a tradução ASCII CR/LF não ocorra.

Exemplo

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

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

pt/readbyte.txt · Last modified: 2020/02/28 10:46 (external edit)