Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 33
Writing to a File on a Multiple-File
Labeled Tape Volume
Writing to the File
Use the DEFINE created above for appending to the file as follows:
1. Open the DEFINE using the FILE_OPEN_ procedure. If the DEFINE attributes
match the attributes in the tape label, then the file is opened. If you are opening
the file with write-only access or with the USE attribute set to “OUT,” then the file is
created and opened. The VOLUME attribute is optional when the USE attribute is
set to “OUT.”
The returned file number relates 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 WRITEX 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 ':=' "=TAPEFILE^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);
.
.
Writing to a File on a Multiple-File Labeled Tape Volume
If the labeled tape contains multiple files, the procedure for writing records to the file is
similar to that for writing to the only file on a labeled tape volume. Again you need to