EasyManua.ls Logo

Commodore 1570 - Page 67

Commodore 1570
132 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
1520 GOSUB 60000
9980 CLOSE
15
9990 END
59980 REM CHECK DISK SUBROUTINE
60000 IF
DS>
1 AND
DS<>50
THEN PRINT
DS,DS$:STOP
60010 RETURN
And
the
command channel
closed
Before
we
end the pro-
gram
Error check subroutine
Ignore "RECORD NOT
PRESENT"
Two lines require additional explanation. When line 1470 executes, the disk drive will
operate for up
to
several minutes, creating all the records
in
the file,
up
to
the maximum
record number you selected in line 1390. This
is
normal, and only needs
to
be done once.
During the process you may hear the drive motor turning and an occasional slight click as
the head steps from track to track. Second, line 60000 above
is
different from the
equivalent line in the error check subroutine given earlier. Here disk error number 50
is
specifically ignored, because
it
will be generated when the error channel
is
checked
in
line
1460. Ignore it because not having a requested record would only be
an
error if that record
had been created previously.
EXPANDING A RELATIVE FILE
What
if
you underestimate your needs and need
to
expand a relative
file
later? No
problem. Simply request the record number you need, even if it doesn't currently exist
in
the file.
If
there is no such record yet, DOS will create it as soon as you
try
to
write
information in it, and also automatically create any other missing records below
it
in
number. When the first record beyond the current end record is written, the DOS returns
"50,
Record Not Present" error. This
is
expected and correct.
WRITING RELATIVE FILE DATA
The commands used to read and write relative file data are the same
PRINT#,
INPUT#,
and
GET#
commands used
in
the preceding chapter on Sequential files. Each
command is used as described there. However, some aspects
of
relative file access do
differ from sequential
file
programming, and
we
will cover those differences here.
DESIGNING A RELATIVE RECORD
As
stated earlier in this chapter, each relative record has a fixed length, including all
special characters. Within that fixed length, there are two popular ways to organize
various individual fields
of
information. One
is
free-format, with individual fields varying
in length from record
to
record, and each field separated from the next by a carriage return
character (each
of
which does take up one character space
in
the record). The other
approach
is
to use fixed-length fields, that
mayor
may not be separated
by
carriage
returns.
If
fixed length fields are not all separated
by
carriage returns, you will either need
59

Related product manuals