Commodore 2001-8 User Manual page 73

Table of Contents

Advertisement

Logical file #3 has been opened
Logical file#3 has been assigned to tape unit #1 (default "1")
Tape unit #1 has been instructed to read from tape (default "0")
No file name referred to
This statement, or expression, is interpreted by BASIC, and could, therefore, use computed logical file
numbers, device numbers or secondary address data. This capability is extremely useful when handling
multiple file devices such as discs.
The keyword OPEN and the logical file numbers are essential in order to open a file; that is address a
device in preparation for a "read" (INPUT #) or a "write"(PRINT #).
The device number is optional; if not entered, the default value "1" will be used.
A file name is optional, though preferred, for the tape units: however, a name would be essential for a disc
storage unit.
EXAMPLES OF OPEN STATEMENTS
The statement OPEN 1,2,1 is interpreted by the operating system as saying:
Parameter
(LF)
Logical file #1 has been opened
(D)
Logical file #1 has been assigned to tape unit#2
(SA)
Tape unit #2 has been instructed to write on tape
(FN)
A file name has
no~
been assigned to the tape record
Similarly, OPEN 3 is interpreted as saying:
(F)
Parameter
(IF)
(D)
(SA)
(FN)
If a PET printer is assigned "4" as a device number, then OPEN 12,4,1 is interpreted as:
Parameter
(LF)
Logical file #12 has been opened
(D)
Logical file #12 has been assigned to device #4
(SA)
Printer has been instructed to print under format statement control
(FN)
File name not applicable
Note: The PET has
a
special system with OPEN for tape files, The opening of the tape
is
automatic, but
the tape header may not always be written at the beginning of the tape buffer; this implies that the
operating system does not always correctly initialize the buffer point. For consistent and reliable
operation of the tape fife header, the fof/owing statements should be used:
1) For tape #1:
POKE 243,122
POKE 244,2
2) For tape #2:
POKE 243,58
POKE 244,3
These should be written prior to each OPEN for write.
lOAD
A special case of the OPEN command is the LOAD of a named file: a LOAD is done with the following statement:
LOAD name, device number
The operating system automatically generates an OPEN using the appropriate secondary addresses for
"load". This OPEN causes the loading device to search for a program name. After the program is found, it is
automatically read from the device and loaded into memory starting at an address specified in the file
header. Most reading errors on the first pass through that program are automatically fixed on the second pass.
At the end of the load cycle, a checksum error, of the total program is made. It a checksum error, or if an
70

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pet 2001-8

Table of Contents