Chapter
10
I
BASIC Keywords
E
OF/Communications
Function
EOF(
buffer)
Detects an empty input queue
for
communications files.
Buffer
is the number assigned
to
the file when you opened it. It
must access an open file.
The value EOF returns depends on the mode (ASCII
or
binary)
in which the file was opened. In ASCII mode, EOF returns a
-1
(true) if a CONTROL-Z is received. EOF remains true until the
device is closed. In binary mode, EOF returns a
-1
(true) when
the input queue is empty. EOF becomes false when the input
queue is not empty.
Sample
Program
These lines are useful in a program when you want
to
run the
program while waiting for communications activity.
10 OPEN "COM1:300,N,8,1"
AS
1
20 COM(1) ON
30 ON COM(1
1
GOSUB
1000
1000 "Communication Subroutine
Begin5
Here
io50
IF
EOF(1) THEN RETURN
Line 10 opens
a
file
for
Communications Channel
1
and allocates
Buffer
1.
Line 30 causes BASIC to perform the subroutine begin-
ning at Line 1000
as
soon as there is activity on the communi-
cations channel. When all the communications data has been
processed, Line 1050 returns to the main program.
151