PRINT#
The Print External statement (PRINT#) outputs one or more data items from
the
PET
to
an
external peripheral device.
Format:
PRINT#
{
file,data
file,data:c:data:c:
...
data
Output
data item.
Output
data items.
c
data
where:
file
is
the logical file number
that
was given when
the file was opened.
is
a
constant
variable, or expression represent-
ing a data item to
be
output. The type of varia-
ble - string or numeric - determines the for-
mat in
which
the data
is
written.
is
an
item separator to
be
output
between
multiple data items. This may
be
a stng or string
variable. Item separators recognized by
INPUT#
statements are:
Comma:
","
or CHR$(44)
RETURN:
CHR$(141)
When
outputting
a single data item, the data item
is
output
and then a
RETURN
code
is
output. On subsequent reading of the file, the
INPUT#
statement
recognizes separate data items by a
<RETURN>
between them:
data <
RETURN
> data <
RETURN
> data <
RETURN
>
...
data <
RETURN
>
When
outputting
multiple
data items
in
one PRINT#
statement
the items
must
be
separated by a valid item separator for subsequent
INPUT#
reads. Stan-
dard punctuation marks, like commas between items, are recognized by
PET
BASIC
but
are
not
transmitted to the
output
file. The
writing
of the item separa-
tors
must
be
forced by including them
as
strings:
PRINT
#file.data;
".";
data;
",";
data
...
or (equivalent):
PRINT#file,data;CHR$(44);data;CHR$(44) :data
...
This results
in
a file
that
is
stored
as:
data.data,data
....
data <
RETURN
>
...
EOF
For
output
to
cassette tape. the data item or items
in
a PRINT# statement
are accumulated in a 192-character buffer.
When
the buffer
is
fi lied. its contents
are
output
to the external device. Note
that
for INPUT#, no more than
80
charac-
ters can
be
read between each
RETURN.
PRINT# may
be
executed in immediate or program mode
but
is
valid only
when referencing a logical file
that
has
been opened for output.
CAUTION:
The form ?# cannot
be
used
as
an
abbreviation for PRINT#.
145