Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 44
Reading From the Only File on a
Labeled Tape Volume
ATTRIBUTE^VALUE ':=' "IN" -> @S^PTR;
ERROR := DEFINESETATTR(ATTRIBUTE^NAME,
ATTRIBUTE^VALUE,
@S^PTR '-' @ATTRIBUTE^VALUE,
DEFAULT^NAMES);
IF ERROR <> 0 THEN ...
!Create the DEFINE:
DEFINE^NAME ':=' "=TAPEFILE^READ ";
ERROR := DEFINEADD(DEFINE^NAME);
IF ERROR <> 0 THEN ...
Reading From the File
Use the DEFINE created above for reading from 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. 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 records from the file using the READ[X] procedure.
The following code fragment reads 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 before the application can make
use of the returned record block.
LITERAL SPACE^FORWARD = 9,
BUFFERED^MODE = 99,
ON = 1;
.
.
!Open the tape file:
FILE^NAME ':=' "=TAPEFILE^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;