Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 89
Accessing an Unlabeled Tape File: An Example
²
If you are reading and sequence numbers were written on tape, keep track of the
sequence number of the current record. Then if a path error occurs, retry the
operation. If the expected sequence number is not read, meaning that a record
was skipped over when the path error occurred, backspace the tape x records,
where x is the sequence number on tape minus the last known sequence number.
For example, assume the current sequence number is 3 and you issue another
read request:
The read request returns a path error. The tape may have moved forward one record
or it may have stayed where it was. Now retry the read request. If the request returns
the record with sequence number 4, then the tape did not move and you have the
record you wanted. If the read returns the record with sequence number 5, then the
tape did move. You now need to space the tape backward two records (5 minus 3) to
read the record with sequence number 4.
Accessing an Unlabeled Tape File: An
Example
This subsection shows a sample program that performs an application similar to the
labeled-tape program earlier in this section. The difference is that this program uses
unlabeled tape. Major coding differences are as follows:
The program opens the magnetic tape device directly by name.
The program must do its own file positioning. That is, the tape does not get
automatically positioned at the beginning or end of a file when opened. The
program must use CONTROL operations to position the tape.
When writing to a scratch tape, the program can initialize the tape itself by simply
writing two EOF marks after the BOT sticker. A separate function selects
procedure SCRATCH^TAPE to do this.
The program performs additional error checking following errors that might occur
during reading or writing the tape file. A sequence number included in each record
makes this possible. The following procedures provide this error checking:
The TAPE^WRITE^ERRORS procedure is called by APPEND^RECORD
whenever an error occurs on writing to tape. This procedure displays a
message telling the user that an error has occurred and also prints the file-
system error number. Because the program uses buffered mode, however, the
064CDT .CDD
Read
Head
RecordRecord Record