FILE_READLN

FILE_READLN N,V

READS THE CURRENT LINE OF THE TEXT FILE NUMBER N AND STORES IT INTO VARIABLE V

  • Type: Command
  • Parameters: 2
  • Group: Text Files

ACTION

The command FILE_READLN N,V reads a line of text file number N, and stores it into the variable V.

The variable V must be on the same type than for the writing command (FILE_WRITELN), but as the file is a text file, all string variable is suitable.

SYNTAX: FILE_READLN N,V

  • N = file number (integer or real). Must be greater than 0 and less than or equal to the maximum of allowed text file number.
  • V = variable name of type string, or of the same type than type used for writing.

USE

  • The command FILE_READLN is used to read one line of a text file.

ERROR

  • If number N is not a correct expression.
  • If number N exceeds the maximum of allowed text file number.
  • If number N is not used for an open text file.
  • If V is not a correct variable name.
  • If V is not a declared variable.

EXAMPLE

dim a$

rem open a text file for reading

file_open_read 1,"my_file.txt"

rem print all its lines

while file_eof(1) <> 1

file_readln 1,a$:print a$

end_while

rem close it

file_close 1

SEE ALSO

FILE_CLOSE

FILE_EOF()

FILE_OPEN_APPEND

FILE_OPEN_READ

FILE_OPEN_WRITE

FILE_READ

FILE_READBUF

FILE_READLN$()

FILE_WRITE

FILE_WRITEBUF

FILE_WRITELN