Readbyte
ReadByte (Función)
Formato
readbyte
readbyte ( )
readbyte ( número_de_archivo_abierto )
devuelve expresión_entera
Descripción
Lee y devuelve el siguiente byte (8 bits) de un archivo abierto, como un número de 0 a 255. Si no se indica el número de archivo, se usa el número cero (0).
El archivo debe abrirse con la instrucción Openb para que no se haga la conversión ASCII de CR/LF.
Si estás leyendo un puerto serie abierto con OpenSerial, no se hace ninguna conversión. Además, se devuelve -1 si no había datos en el búfer de recepción.
Ejemplo
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
mostrará algo parecido a
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
Véase también
Changedir, Close, Currentdir, Dir, Eof, Exists, Freefile, Kill, mkdir, Open, Openb, OpenFileDialog, OpenSerial, Read, Readbyte, Readline, Reset, SaveFileDialog, Seek, Size, Write, Writebyte, Writeline
Historial
| 1.1.4.0 | Se añadió el puerto serie |