
Closing the file
When you have finished with your file, close it using the
keyword CLOSE#.
EXAMPLES
CLOSE#X
means: close channel X; I have finished with the file.
CLOSE#0
means: close all my open files.
Other random access operations
You can use the keyword EXT# to find out how many bytes have
been written to the file.
EXAMPLE
SIZE=EXT#X
This means: into the variable SIZE put the size, in bytes, of
the file with channel X.
The keyword EOF# is used to tell whether the end of the file has
been reached. It is set to true (-1) if the end has been reached, or
false (0) if it hasn't.
EXAMPLE
10 X=OPENIN("DATA")
20 REPEAT
30 A=BGET#X
40 UNTIL EOF#X
50 CLOSE#X
This means: continue to read bytes from the file with channel X
— in this example, the file DATA — until the last byte has been
read.
There are two more keywords which read and write data to an
open file. INPUT# reads data; PRINT# writes data. These
keywords are used to read and write BASIC variables, rather
than single bytes.
42