Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 47
Reading From a File on a Multiple-File Labeled
Tape Volume
DEFAULT^NAMES);
IF ERROR <> 0 THEN ...
!Set the USE attribute to IN:
ATTRIBUTE^NAME ':=' "USE ";
ATTRIBUTE^VALUE ':=' "IN" -> @S^PTR;
ERROR := DEFINESETATTR(ATTRIBUTE^NAME,
ATTRIBUTE^VALUE,
@S^PTR '-' @ATTRIBUTE^VALUE,
DEFAULT^NAMES);
IF ERROR <> 0 THEN ...
!Set the EBCDIC attribute to IN:
ATTRIBUTE^NAME ':=' "EBCDIC ";
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 ':=' "=FILE^FIVE^READ ";
ERROR := DEFINEADD(DEFINE^NAME);
IF ERROR <> 0 THEN ...
Reading From the File
Use the DEFINE created above for reading from the file as described below.
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. 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. 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 separate each record block into four records before the application can make
use of the data.
LITERAL SPACE^FORWARD = 9,
BUFFERED^MODE = 99,
ON = 1;
.
.
!Open the tape file:
FILE^NAME ':=' "=FILE^FIVE^READ" -> @S^PTR;
ERROR := FILE_OPEN_(FILE^NAME:@S^PTR '-' @FILE^NAME,