Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 75
Writing to a Single-File Unlabeled Tape
Writing a New File to a Scratch Tape
Writing a file to magnetic tape involves two steps:
1. Write records to the tape device using the WRITE procedure; for example:
!Write record blocks to tape:
WHILE NOT DONE
BEGIN
.
.
!Write one record to tape:
CALL WRITEX(TAPE^NUM,
SBUFFER,
WCOUNT);
IF <> THEN ...
.
.
IF <no more to write> THEN DONE = 1;
END;
2. Terminate the file with an end-of-file mark and an indication of end of tape.
Because there is only one file on the tape, you could get away without a separate
convention for indicating the end of the tape. However, it is worth observing an
end-of-tape convention, regardless of how many files the tape contains. In addition
to providing consistency between multiple-file and single-file tapes, you will need
the end-of-tape convention if you add files to the tape later. Therefore we
recommend terminating this file with the HP end-of-tape convention: two end-of-
file marks.
The following code fragment writes two EOF marks to the tape:
LITERAL WRITE^EOF = 2;
.
.
!Write EOF mark to signify end of file:
CALL CONTROL(TAPE^NUM,
WRITE^EOF);
IF <> THEN ...
!Write another end-of-file mark to signify end of tape:
CALL CONTROL(TAPE^NUM,
WRITE^EOF);
IF <> THEN ...