Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 4
Positioning the Tape
3. Perform read or write operations on the magnetic tape (using the READ[X] or
WRITE[X] procedures). See Reading and Writing Tape Records later in this
section for details.
4. Terminate access to the magnetic tape (using the FILE_CLOSE_ procedure). See
Terminating Tape Access later in this section for details.
The correct method for opening the magnetic tape device depends on whether the
tape you access is labeled or unlabeled. A labeled tape device is always opened by
passing the name of a DEFINE as the file-name parameter to the FILE_OPEN_
procedure; for example:
FILE^NAME ':=' "=TAPE^FILE";
LENGTH := 10;
ERROR := FILE_OPEN_(FILE^NAME:LENGTH,
TAPE^NUM);
IF ERROR <> 0 THEN ...
=TAPE^FILE is assumed to be a DEFINE that describes a file on the labeled tape.
Subsequent access to the file on tape is made through the file number returned in the
TAPE^NUM variable.
Details about setting up the DEFINE are given with specific examples in Working With
Standard Labeled Tapes later in this section.
You gain access to an unlabeled tape by opening the device by name (or logical device
number) or by using a DEFINE that describes the device. The following example
opens the tape device $TAPE1 by name:
FILE^NAME ':=' "$TAPE1";
LENGTH := 6;
ERROR := FILE_OPEN_(FILE^NAME:LENGTH,
TAPE^NUM);
IF ERROR <> 0 THEN ...
Refer to Working With Unlabeled Tapes later in this section for further details about
opening unlabeled tapes, including an example of using a DEFINE.
Positioning the Tape
The CONTROL procedure has several operations that move the tape backward and
forward by a specific number of files or record blocks:
Space forward a number of files using CONTROL operation 7.
Space backward a number of files using CONTROL operation 8.
Space forward a number of record blocks using CONTROL operation 9.
Space backward a number of record blocks using CONTROL operation 10.
Rewind the tape using CONTROL operation 3, 5, or 6.