Table of Contents

GET#

The GET# statement is used to read a single character from a file. The file must be opened beforehands with the same logical file number, using the OPEN statement.

Syntax

GET #<logical file no>, <variable>

The character that is read from the file is assigned to the specified variable as per the following rules:

  • If the variable is of a numeric type, it will be assigned the numeric PETSCII code of the character,
  • If the variable is a STRING, it will assigned the character itself, as string.

Warning

The variable must be pre-defined.

Examples

REM -- dump raw contents of a file
DIM char$ AS STRING * 1
CONST EOF = 64
OPEN 2, 8, 2, "filename"
DO WHILE ST() <> EOF
  GET #2, char$
  PRINT char$;
LOOP
CLOSE 2