Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 37
Writing to a File on a Multiple-File
Labeled Tape Volume
!Create the DEFINE:
DEFINE^NAME ':=' "=TAPEFILE5^APPEND ";
ERROR := DEFINEADD(DEFINE^NAME);
IF ERROR <> 0 THEN ...
Writing to the File
Use the DEFINE created above for appending to the file as described below. Note that
you can append only to the last file on the tape. So, in this case, the fifth file must also
be the last file.
1. Open the DEFINE using the FILE_OPEN_ procedure. If the file exists and the
DEFINE attributes match those on the tape label, then the file is opened. If the file
does not exist, it is created and opened; the file sequence number must be one
greater than that of the last file on the tape.
The returned file number is related to the tape drive that the tape is mounted on.
2. Turn on buffered mode, if desired, using SETMODE function 99.
3. Write records to the file using the WRITE[X] procedure.
The following code fragment writes to the tape using the DEFINE created above. Note
that because the record block is four times the size of the record, the application needs
to block four records into one record block before the record block is written to tape in
one write operation.
LITERAL BUFFERED^MODE = 99,
ON = 1;
.
.
!Open the tape file:
FILE^NAME ':=' "=TAPEFILE5^APPEND" -> @S^PTR;
ERROR := FILE_OPEN_(FILE^NAME:@S^PTR '-' @FILE^NAME,
TAPE^NUM);
IF ERROR <> 0 THEN ...
!Set buffered mode:
CALL SETMODE(TAPE^NUM,
BUFFERED^MODE,
ON);
IF <> THEN ...
.
.
!Block four records into the output buffer:
SBUFFER[0] ':=' LOGICAL^BUFFER^1[0] FOR 512;
SBUFFER[512] ':=' LOGICAL^BUFFER^2[0] FOR 512;
SBUFFER[1024] ':=' LOGICAL^BUFFER^3[0] FOR 512;
SBUFFER[1536] ':=' LOGICAL^BUFFER^4[0] FOR 512 -> @S^PTR;
!Write a record block to the tape file:
CALL WRITEX(TAPE^NUM,
SBUFFER,
@S^PTR '-' @SBUFFER);