Print# And Input - Commodore 1541 User Manual

Disk drive
Hide thumbs Also See for 1541:
Table of Contents

Advertisement

PRINT# and INPUT#
The PRINT# command works exactly like the PRINT statement, except that out
put is re-directed to the disk drive. The reason for the special emphasis on the word ex
actly is that all the formatting capabilities of the PRINT statement, as applies to punc
tuation and data types, applies here too. It just means that you have to be careful when
putting data into your files.
FORMAT FOR WRITING TO FILE WITH PRINT#:
PRINT# file#, data list
The file# is the one from the OPEN statement when the file was created.
The data list is the same as the regular PRINT statement — a list of variables
and/or text inside quote marks. However, you must be especially careful when writing
data so that it is as easy as possible to read the data back again.
When using the PRINT# statement, if you use commas (,) to separate items on the
line, the items will be separated by some blank spaces, as if it were being formatted for
the screen. Semicolons (;) don't result in any extra spaces.
In order to more fully understand what's happening, here is a diagram of a se
quential file created by the statement OPEN 5, 8, 5, "O:TEST,S,W":
eof
char
1
10
11
12
13
14
15
The eof stands for the end-of-file marker. String data entering the file goes in byte
by byte, including spaces.
For instance, let's set up some variables with the statement A$= "HELLO";
B$ = "ALL": C$ = "BYE". Here is a picture of a file after the statement PRINT# 5,
&;B$
char
H
1
E
2
L
3
L
4
0
5
A
6
L
7
L
8
B
9
Y
10
E
11
CR
12
eof
13
CR stands for the CHR$ code of 13, the carriage return, which is PRINTed at the
end of every PRINT or PRINT# statement unless there is a comma or semicolon at the
end of the line.
NOTE: Do not leave a space between PRINT and #, and do not try to abbreviate the
command as ?#. See the appendixes in the user manual for the correct abbreviation.
FORMAT FOR INPUT# STATEMENT:
INPUT* file#, variable list
21

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents