Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 25
Accessing Labeled Tapes
Specifying the I/O Operation
You must specify the type of I/O operation you want to perform on the labeled tape.
You can write a new file, read from an existing file, or append to an existing file. You
can specify the I/O operation using either the access parameter of the FILE_OPEN_
procedure or the USE DEFINE attribute.
To specify reading, either set the access parameter of the FILE_OPEN_ procedure for
read-only access or set the USE attribute to “IN.” In either case, when the file is
opened, the tape is positioned immediately before the first record in the file.
For writing a new file, you can either set the access parameter of the FILE_OPEN_
procedure for write-only access or set the USE attribute to “OUT.” When the open
finishes, an empty file is created ready to be written.
Appending can be specified only by setting the USE attribute to “EXTEND.” When the
file is opened, the tape is positioned at the end of the file ready for appending. The file
must be the last file in a file set or an error condition is returned.
An example of how to set the USE attribute follows:
ATTRIBUTE^NAME ':=' "USE "; !16 bytes
VALUE ':=' "EXTEND" -> @S^PTR;
ERROR := DEFINESETATTR(ATTRIBUTE^NAME,
VALUE,
@S^PTR '-' @VALUE,
DEFAULT^NAMES);
IF ERROR > 0 THEN ...
Selecting the Conversion Mode
Tapes with IBM labels are encoded in EBCDIC notation. Information taken from these
tapes must be converted into ASCII code before the HP system can use it.
Conversely, data written to a tape with IBM labels must be converted from ASCII code
to EBCDIC code before being written to tape.
Use the EBCDIC DEFINE attribute to perform code conversion. You must specify this
attribute whenever you access a tape with IBM labels (the LABELS attribute is set to
“IBM”). Set the EBCDIC attribute to “IN” for reading from the tape file or “OUT” for
writing or appending to the tape file; for example:
ATTRIBUTE^NAME ':=' "EBCDIC "; !16 bytes
VALUE ':=' "IN" -> @S^PTR;
ERROR := DEFINESETATTR(ATTRIBUTE^NAME,
VALUE,
@S^PTR '-' @VALUE,
DEFAULT^NAMES);
IF ERROR > 0 THEN ...
ANSI tapes are already in ASCII form and therefore do not need converting.