If the final argument of a PRINT# statement is
a semicolon or comma, PRINT# will not append the (default) CR/LF byte
pair to the data as it is written to the file. For example:
PRINT #1, "Hello";
PRINT #1, " world!"
...produces the contiguous string "Hello world!"
in the disk file.
If you omit all arguments, the PRINT# statement prints
a blank line in the file (i.e., a CR/LF pair only), but you must include
the comma after the file number. Because PRINT# writes an image
of the data to the file, you must delimit the data so it is printed correctly.
If you use commas as delimiters, PRINT# also writes the blanks between
print fields to the file. Also, remember that spacing of data displayed
on a text screen using monospaced characters may not work well when the
data is redisplayed in a graphical environment using proportionally spaced
characters.
If you are not careful, you can waste a lot of disk
space with unnecessary spaces, or worse, put fields so close together
that you cannot tell them apart when they are later input with INPUT#.
For example:
PRINT #1,1,2,3
sends:
1
2 3
to file #1. Because of the 14-column print
zones between characters, superfluous spaces are sent to the file.
On the other hand:
PRINT #1,1;2;3
sends:
1 2 3
to the file, and you cannot read the separate numeric
values from this record because INPUT# requires commas as delimiters.
The best way to delimit fields is to put a comma between each field, like
so:
PRINT #1, 1 "," 2 "," 3
which writes:
1, 2, 3
to the file, and wastes the least possible space
and is easy to read with an INPUT#
statement. The WRITE# statement delimits
fields with commas automatically.
PRINT# is advantageous when writing a single
number or
string on each line in a file. Use PRINT# followed by a comma but
no arguments to write a blank line (carriage return/linefeed) to a file:
PRINT #1, 'writes a blank line to file
#1 |