EOF¶
Function¶
EOF checks for end of file.
Syntax¶
EOF(file no)
Examples¶
10 OPEN "DATA.TXT" FOR INPUT AS #1
20 INPUT#1,A,B,C
30 PRINT A,B,C
40 IF EOF(1) THEN CLOSE #1 ELSE GOTO 20
50 PRINT "END OF FILE":END
Remarks¶
EOF = -1 if end of file has been reached
EOF = 0 if more data is in the file
Programs should not try to read beyond the end of a file since an error will occur.
The file DATA.TXT used in this example, could be created by a Basic program of the form:
100 OPEN "DATA.TXT"FOR OUTPUT AS #1
110 WRITE#1, 123,235,345
120 CLOSE#1
130 END
This will ensure that the correct end of file marker is written to the file.