Syntax
|
EOF
(filenumber)
|
Description
|
Returns
True
if the end-of-file has been reached for the given file; returns
False
otherwise.
|
Comments
|
The filenumber parameter is an
Integer
used by the Basic Control Engine to refer to the open file—the number passed to the
Open
statement.
With sequential files,
EOF
returns
True
when the end of the file has been reached (i.e., the next file read command will result in a runtime error).
With
Random
or
Binary
files,
EOF
returns
True
after an attempt has been made to read beyond the end of the file. Thus,
EOF
will only return
True
when
Get
was unable to read the entire record.
|
Example
|
This example opens the autoexec.bat file and reads lines from the file until the end-of-file is reached.
Const crlf = Chr$(13) + Chr$(10)
Sub Main()
file$ = "c:\autoexec.bat"
Open file$ For Input As #1
Do While Not EOF(1)
Line Input #1,newline
Loop
Close
MsgBox "The last line of '" & file$ "' is:" & crlf & crlf & newline
End Sub
|
See Also
|
Open (statement); LOF (function).
|