EOF Function

Purpose:

To return -1 (true) when the end of a sequential or a communications file has been reached, or to return 0 if end of file (EOF) has not been found.

Syntax:

v=EOF(file number)

Comments:

If a GET is done past the end of the file, EOF returns -1. This may be used to find the size of a file using a binary search or other algorithm. With communications files, a -1 indicates that the buffer is empty.

Use EOF to test for end of file while inputting to avoid "Input Past End" errors.

Examples:

10 OPEN "I", 1, "DATA"
20 C=0
30 IF EOF(1) THEN 100
40 INPUT#1, M(C)
50 C=C+1: GOTO 30
100 END

The file named DATA is read into the M array until the end of the file is reached, then the program branches to line 100.