Tandy 1000 Basic Reference Manual page 152

Hide thumbs Also See for 1000:
Table of Contents

Advertisement

Chapter 10
I
BASIC Keywords
EOF
Function
E OF( buffer)
Detects the end of a file.
Buffer is the number assigned to the file when you opened it. It
must access an open file.
This function checks t o see whether all characters up
t o
the end-
of-file marker have been accessed so that you can avoid "Input
past end" errors during sequential input.
When used with sequential access files, EOF returns 0 (false),
when the end-of-file record has not been read yet, and -1 (true),
when it has been read.
When used with direct access files, EOF returns -1 (true) if the
last executed GET statement was unable t o read an entire record
because of an attempt t o read beyond the physical end of the file.
Sample Program
The following sequence of lines reads numeric data from
&ta.txt
into the array AO. When the last data character in the file is
read. the EOF test in Line 30 is true. so the program branches
out of the disk access loop.
1 4 7 0
D I M A ( 1 0 0 )
' A S S U M I N G T H I S
1 4 8 0 OPEN
" I " ,
1 ,
" d a t a . t x t "
1 4 9 0
I %
=
0
1 5 0 0 I F E O F ( 1
1
T H E N GOTO 1 5 4 0
1 5 1 0 I N P U T # I ,
A(I%)
1 5 2 0
I %
=
I %
+
1
1 5 3 0 GOTO 1 5 0 0
1 5 4 0 REM PROG. C O N T . HERE A F T E R
I S
A S A F E V A L U E
D I S K I N P U T
150

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents