Read

Read filenum%, variable, var_size%


Reads data from the specified file number.
The file must first be opened in input-mode before this command can be used.
Reads occur at the position specified by the file pointer (see also Seek and FTell).
Data read from file will be placed into a variable.
Read statement overwrites the destination variable content with data content. 
If the variable does not exist, it will be created.
Using a byte vector variable or a string the size may be any positive integer value.
Using plain type variable like integer or float the size must be equal to this variable size.

Example, how to print out a content of text file:

Rem print out a file text content
Input "Insert file path >", filename$

Rem Open the file for input with number 1
FOpen filename$, "r", 1

size%=FSize(1) : ' Get size of the input file
Read 1, text$, size% : ' Read file content and place it into text$

' If no error occurs, then print out the text
If FError(1)=0 Then Print text$ Else Print "Error reading "; filename$

' Close the open file
Close 1
Comments