Chapter
10
I
BASIC
Keywords
LO
C/C
ommunic at ions
Function
LOC
(buffer)
Returns the number of characters in the input queue if that
number is
255
or
less.
If the queue contains
256
or more characters, the LOG function
returns the number
255.
Since a string is limited to
255
charac-
ters, this limit eliminates the need for testing string size before
reading data into the queue.
Buffer
is the number assigned
to
the file when you opened it.
The default size
for
the input queue is
256
characters, but you
can change the size by using the
/C:
option when loading BASIC.
Ex
ample
10
X=LOC<I)
20
If
X>0
THEN
A$=INPUT$(LOC(l),#I)
Line
18
checks
to
see if there are any characters in the input
queue and stores the number
of
characters in the variable
X.
Line
20
tests the value
of
X.
If
X
is greater than
0,
there are
characters in the input queue, and Line
28
returns the charac-
ters in the buffer into A$.
Notice from the example that INPUT$ is preferred over LINE
INPUT#
or
INPUT# when reading communications files. This
preference is because all ASCII characters might be significant
in communications. INPUT$ allows all characters to be read.
The other statements do not. LINE INPUT# stops at a carriage
return. INPUT# stops at a comma
or
a carriage return.
208