Commodore 1541-II User Manual page 51

Hide thumbs Also See for 1541-II:
Table of Contents

Advertisement

Before we study the format of the Open statement, let's review some of the possible
devices in a Commodore computer system:
Device #: Name:
0
1
2
3
4
8
Keyboard
DATASSETTE
RS232
Screen
Printer
Disk drive
Used for:
Receiving input from the computer operator
Sending and receiving information from cassette
Sending and receiving information from a Modem
Sending output to a video display
Sending output to a hard copy printer
Sending and receiving information from diskette
Because of the flexibility of the Open statement, it is possible for a single program
statement to contact any one of these devices, or even others, depending on the value of a
single character in the command. Often an Open statement is the only difference between
a program that uses a DATASSETTE™ and one using the 1541. If the character is kept in
a variable, the device used can even change each time that part of the program is used,
sending data alternately and with equal ease to diskette, cassette, printer and screen.
REMEMBER TO CHECK FOR DISK ERRORS!
In the last chapter we learned how to check for disk errors after disk com
mands in a program. It is equally important to check for disk errors after using file-
handling statements. Failure to detect a disk error before using another file-
handling statement could cause loss of data, and failure of the Basic program.
The easiest way to check the disk is to follow all file-handling statements with
a Gosub statement to an error check subroutine.
EXAMPLE:
840 OPEN 4,8,4,"0:DEGREE DAY DATA,S,W"
850 GOSUB 59990:REM CHECK FOR DISK ERRORS
FORMAT FOR THE DISK OPEN STATEMENT:
OPEN file #, device #, channel #,"drive #:file name,file type,direction"
where:
"file #" is an integer (whole number) between 1 and-255. If the file number is
greater than 127, a line-feed character is inserted after each carriage return in the file
opened. Though this may be helpful in printer files, it will cause severe problems in disk
files, and is to be avoided at all costs. Do not open a disk file with a file number greater
than 127. After the file is open, all other file commands will refer to it by the number
given here. Only one file can use any given file number at a time.
"device #" is the number, or primary address, of the device to be used. This
number is an integer in the range 0-31, and is normally 8 on the 1541.
43

Advertisement

Table of Contents
loading

Table of Contents