Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 84
Reading From a File on Multiple Unlabeled Tape
Reels
Reading From a File on Multiple Unlabeled Tape Reels
The technique for reading records from a multiple-reel file depends in part on what
information you have put in the tape header. Typically, your program is going to use
the header information to determine whether the current reel is the first or last reel in
the file. The program needs to know this to determine how to interpret the pair of EOF
marks at the end of the information on the tape or how to interpret the BOT sticker.
If your program is record spacing forward and encounters the two EOF marks, the
program should return a “record not found” message to the user if the current tape reel
is the last in the file. Otherwise, the program should issue CONTROL function 24 to
rewind the tape and request the next tape. Similarly, if the program encounters the
BOT sticker, it needs to know whether to request that the user mount the previous
tape.
Terminating Tape Access
You terminate access to a tape drive either by closing the device or by stopping the
application. The technique is the same for labeled and unlabeled tapes: you close a
tape device as you would any file, by issuing a FILE_CLOSE_ procedure call.
We recommend rewinding and unloading the tape before closing the file. You can do
this by specifying 0 (the default value) for the tape-disposition parameter of
FILE_CLOSE_. (You can also do it through the CONTROL procedure). You should
turn off buffered mode before closing the tape device to ensure that all data is written
to tape.
The following code fragment turns off buffered mode, rewinds and unloads the tape,
and closes the tape file:
LITERAL BUFFERED^MODE = 99,
ON = 1,
OFF = 0,
REWIND^UNLOAD = 0;
.
.
CALL SETMODE(TAPE^NUM,
BUFFERED^MODE,
OFF);
IF <> THEN ...
ERROR := FILE_CLOSE_(TAPE^NUM,
REWIND^UNLOAD);
IF ERROR <> 0 THEN ...
Note. With unlabeled tape, the application does not wait for the rewind-and-unload operation
to complete; with labeled tape, the application waits for the operation to complete.