Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 51
Reading From a File on Multiple Labeled Tape
Volumes
Reading From the File
Use the DEFINE created above for reading the file as described below. Note that the
DEFINE refers to the third tape of a four-tape file.
1. Open the DEFINE using the FILE_OPEN_ procedure. If the file section exists and
the DEFINE attributes match those on the tape label, then the tape file is opened.
The returned file number refers to the tape drive that the tape is mounted on.
2. Turn on buffered mode, if desired, using SETMODE function 99.
3. Read record blocks from the file using the READ[X] procedure.
The following code fragment reads record blocks from 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 deblock each record block into four records.
LITERAL SPACE^FORWARD = 9,
BUFFERED^MODE = 99,
ON = 1;
.
.
!Open the tape file:
FILE^NAME ':=' "=THIRD^TAPE^READ" -> @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 ...
.
.
!Position the tape to the desired record block:
PHYSICAL^RECORD^ADVANCE := 36;
CALL CONTROL(TAPE^NUM,
SPACE^FORWARD,
PHYSICAL^RECORD^ADVANCE);
!Read a record block from the tape file into the input
!buffer:
RCOUNT := 2048;
CALL READ(TAPE^NUM,
SBUFFER,
RCOUNT,COUNT^READ);
!Deblock the input buffer into four records:
LOGICAL^BUFFER^1[0] ':=' SBUFFER[0] FOR 512;
LOGICAL^BUFFER^2[0] ':=' SBUFFER[512] FOR 512;