Asynchronous Communications
THE INPUT$ FUNCTION FOR COM FILES
The INPUT$ function is preferable to the
INPUT# and LINE INPUT# statements when
reading COM files, since all ASCII characters
may be significant in communications. INPUT#
is least desirable because input stops when a
comma (,) or CR is received and LINE INPUT#
terminates when a CR is received.
INPUT$ allows all characters read to be
assigned to a string. INPUT$ (n,f) will return n
characters from the #f file. The following state-
ments are therefore the most efficient for
reading a COM file:
10 WHILE NOT EOF(1)
20 AS
=
INPUTS(LOC(1),1#1]
30
40 . . . Process data returned in AS
50 ...
60
WEND
The above statements return the characters in
the buffer into A$ and process them, provided
there are characters in the buffer. If there are
more than 255 characters, only 255 will be
returned at a time to prevent String Overflow.
If
this is the case, EOF(l) is false and input
continues until the input buffer is empty. The
sequence of events is therefore simple, concise,
and fast.
6-6