Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 80
Writing to a File on Multiple Unlabeled Tape Reels
Writing Tape Headers
We recommend using tape headers to identify magnetic tape reels, especially where
tape files span multiple tapes. Because we recommend using two EOF marks to
denote the end of information on a tape, headers are needed to identify where a
multiple-reel file starts and stops. For example, when reading a tape sequentially, your
program encounters an EOF mark. The program needs to know whether this is the
end of the file or whether the file continues on another tape.
A tape header usually includes information such as an indication as to whether the
tape is part of a multiple-tape file, the order of the tape in the file, and the total number
of tape reels in the file. It is up to the application designer to choose what information
will go into the tape header.
As an alternative to writing your own tape headers, you can use labeled tapes. See
Working With Standard Labeled Tapes earlier in this section.
Checking for the End of the Tape
When writing out a multiple-reel file, you need to check for the end of the tape. You do
this by checking for the EOT sticker on the tape itself. There may be several records in
the buffers that will still be written out to tape after the EOT sticker is encountered.
Information can therefore be written beyond the EOT sticker. The program should treat
the EOT sticker as a warning that the end of the tape is near and send no more
records to the tape process for writing.
The following code fragment writes records to tape. It issues a SETMODE 120, which
causes the tape process to return error 150 if the EOT sticker is encountered on a
write operation. If EOT is encountered, the program stops writing records and sends
two EOF marks to the tape process to indicate the end of information on the tape.
Error 150 is expected following each of these write operations and is ignored. Finally,
the code fragment issues CONTROL operation 3 to rewind and unload the tape and
calls SETMODE to disable function 120.
LITERAL WRITE^EOF = 2,
REWIND^AND^UNLOAD = 3,
RETURN^ERROR^IF^EOT = 120,
ON = 1,
OFF = 0;
.
.
CALL SETMODE(TAPE^NUM,
RETURN^ERROR^IF^EOT,
ON);
IF <> THEN ...
WHILE NOT DONE
BEGIN
.
.
CALL WRITEX(TAPE^NUM,
SBUFFER,