Chapter
10
I
BASIC Keywords
LPOS
Function
LPOS(num
ber)
Returns the logical position
of
the print head within the printer’s
buffer.
Number
can be 0
or
1
to indicate LPT1:.
LPOS is only useful
for
checking the position
of
the print head
after a LPRINT statement that is terminated by
a
semicolon to
suppress the automatic carriage return. The statement contain-
ing LPOS is not executed until the LPRINT statement is fin-
ished printing.
LPOS does not necessarily give the physical position
of
the print
head if the printed string contains the ASCII code
for
a carriage
return.
For
example, if you
are
printing a string
of
20 characters
and the 10th character is the ASCII code
for
a carriage return,
the printer advances to the next line after printing the ninth
character before printing the remaining 10 characters. If the
string is terminated by a semicolon to supress the automatic line
feed, the physical location
of
the print head is at position 10, but
LPOS returns
a
value
of
21 because that is the logical location
of
the print head.
Example
You may want
to
use LPOS
to
determine whether there is
enough room to continue printing more variables on the same
line.
100
IF
LPOS(X)>60 THEN LPRINT
If the printer has printed more than 60 characters, a carriage
return is sent
so
that the printer skips
to
the next line.
213