Commodore 1541-II User Manual page 35

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

Advertisement

PRINT DS$
or abbreviate it to
?DS$
either in immediate mode or within a program, and the current error status message of the
disk will be displayed on the screen. A message will be displayed whether there is an error
or not, but if there was an error, printing its message will also clear it from the disk
memory and turn off the error light on the disk drive.
Once the message is on the screen, you can look it up in Appendix B to see what it
means, and what to do about it.
ERROR CHECK SUBROUTINE
Since those of you who are writing programs should be checking the error status after
each disk command, you may want to include a small subroutine in each program to take
care of the error channel. Here is one we use:
Basic 2 version:
Basic 3.5 version:
59980 REM READ ERROR CHANNEL
59990 REM READ ERROR CHANNEL
59990 INPUT#15, EN,EM$,ET,ES
60000 IF DS>1 THEN PRINT DS$:STOP
60000 IF EN> 1 THEN PRINT
EN,EM$,ET,ES:STOP
60010 RETURN
60010 RETURN
The Basic 2 version assumes file 15 has already been opened earlier in the program, and
that it will be closed somewhere else at the end of the program.
This subroutine reads the error channel and puts the results into the named variables.
In the Basic 2 version, they are EN, EMS, ET, and ES, which stand for Error Number,
Error Message, Error Track and Error Sector respectively. Of the four, only EM$ has to
be a string, and you could choose other variable names, although these have become
traditional for this use.
The Basic 3.5 version subroutine uses the reserved variables DS and DS$ already set
aside for this purpose. They are updated automatically by Basic whenever they are used.
Otherwise, the two versions of the subroutine are equivalent.
Two error numbers are harmless: 0 means everything is OK, and 1 tells how many
files were erased by a Scratch command. If the error status is anything else, line 60000
prints the error message and halts the program. After you have repaired the damage, you
may then continue the program with Basic's Cont command.
Because this is a subroutine, you access it with the Basic Gosub command, either in
immediate mode or from a program. (For example, "200 GOSUB 59990".) The Return
statement in line 60010 will jump back to immediate mode or the next statement in your
program, whichever is appropriate.
27

Advertisement

Table of Contents
loading

Table of Contents