FutureBasic Logo

<<    Index    >> FutureBasic

read#   statement



Syntax
read# deviceID, { recVar | numVar | strVar$;len } [, { recVar | numVar | strVar$;len }...]

Description
This statement reads data from the open file or serial port specified by deviceID, and stores the data into the indicated variable(s).
You can read the data into record variables (recVar), into numeric variables (numVar) or into string variables (strVar$), or any combination of these. If you specify recVar or numVar, the statement reads a number of bytes equal to the size of the variable, and stores the bytes directly into the variable's location in memory, without doing any data conversion. If you specify strVar$;len, the statement reads len bytes, and stores them into strVar$ as a Pascal string of length len (len can be any numeric expression, but its value should not exceed 255). The read operation begins at the current location of the "file mark," and the file mark is advanced as each item is read. If read# attempts to read past the end of the file, FutureBasic generates an error.
Because read# copies the file's bytes directly into memory without conversion, it's best suited for reading "binary" information, such as that created by the write statement. To read file data which is formatted as text, it's usually better to use the input# statement. To read an arbitrary number of bytes into a block of memory, use the read file statement.

See also
write; input#; read file; eof; open; sizeof