Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 83
Reading From a Multiple-File Unlabeled Tape
Reading From a Multiple-File Unlabeled Tape
Reading records from a multiple-file unlabeled tape reel is similar to the single-file case
except that your program must also space the tape forward or backward to the
appropriate file. The steps your program must perform are outlined below:
1. File space forward or backward to the appropriate file. If you try to space
backward too far, the tape will stop when you reach the BOT sticker. To guard
against spacing forward too far, however, your program should check for the pair of
EOF marks that terminate information on the tape. For example:
LITERAL SPACE^FWD^FILES = 7,
SPACE^FWD^RECORDS = 9;
.
.
NUMBER^OF^FILES := 5;
CALL CONTROL(TAPE^NUM,
SPACE^FWD^FILES,
SPACE^FWD^RECORDS);
IF <> THEN ...
CALL READX(TAPE^NUM,
SBUFFER,
RCOUNT,COUNT^READ);
IF <> THEN
BEGIN
CALL FILE_GETINFO_(TAPE^NUM,
ERROR);
IF ERROR = 1 THEN ... !end of tape reached
ELSE ... !other error
END;
2. Record space forward to the record that you intend to read. If you try to space
forward too far, the CONTROL procedure returns an end-of-file error (error 1). For
example:
NUMBER^OF^RECORDS := 27;
CALL CONTROL(TAPE^FILE,
SPACE^FWD^RECORDS,
NUMBER^OF^RECORDS);
IF <> THEN
BEGIN
CALL FILE_GETINFO_(TAPE^FILE,
ERROR);
IF ERROR = 1 THEN ... !end of file
ELSE ... !other error
END;
3. Read the record:
CALL READX(TAPE^FILE,
SBUFFER,RCOUNT,
COUNT^READ);
IF <> THEN ...