
FORMAT FOR SENDING DISK COMMANDS
OPEN
15,device
#,15,commandS
or
Print#
15
,command$
Examples:
OPEN
15,8,15,"VO"
or
PRINT#l5,"VO"
wher~
"device
#"
is
the disk's device number, normally 8, and
"command$"
is
any
valid string expression .
If
it
is
not also a valid disk command,
it
will result
in
an error on
the disk drive. This
is
indicated by a flashing error light on the disk drive, and an error
message such as
"31,SYNT
AX
ERROR"
when the error channel
is
read
as
described on
the next two pages.
READING
THE
ERROR CHANNEL: BASIC 2
In Basic
2,
there
is
no simple way to learn what
is
causing the error light to flash on
the disk drive without writing a
small program. This,
in
tum, causes you to lose any
program variables already
in
memory. The reason for this is that the
INPUT#
command
cannot easily be used
in
immediate mode (that is, without a line number).
You
will often need to be able to read the disk error channel, to see why the disk error
light
is
flashing, and thereby
tum
the error light
off
again.
Here
is
a brief program to check for disk errors:
10...0PEN 15,8,15
20
INPUT#l5
,
EN,EM$,ET
,
ES
30 PRINT EN,EM$,ET,ES
40CLOSE
15
This little program reads the error channel into 4 Basic variables, and prints the
results on the screen. A message will be displayed whether there
is
an error
or
not, but if
there was an error, this program will also
clear
it
from 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.
READING
THE
ERROR CHANNEL: BASIC 3.5
In Basic
3.5,
it
is
very easy to learn what
is
causing the error light to flash on the disk
drive, and no need to write a program.
Simply type
:.
26
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
Apwndix 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:
59980 REM READ ERROR CHANNEL
59990
INPUT#l5,
EN,EM$,ET,ES
60000 IF
EN>
I THEN PRINT
EN ,EM$,ET ,ES:STOP
60010 RETURN
Basic 3.5 version:
59990 REM READ ERROR CHANNEL
60000
IF
DS>
I THEN PRINT DS$:STOP
600
I 0 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, EM$, 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
nu1T_1bers
are harmless: 0 means everything
is
OK, and I tells how many
fil~s
were erased by a Scratch command.
If
the error status
is
anything else, line 60000
Pnnts 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
•mmediate 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
Comentarios a estos manuales