Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 26
Accessing Labeled Tapes
Specifying the Block and Record Sizes
The BLOCKLEN, RECLEN, and RECFORM attributes allow you to specify how
records are blocked into record blocks. Recall from Blocking Tape Records, earlier
in this section, that a record is a collection of related information as seen by the
application, and that one or more records can be blocked into one record block that is
read from or written to tape in one operation.
You must specify the relationship between record blocks and records using the
BLOCKLEN, RECLEN, and RECFORM attributes. These attributes are required to
provide compatibility with other vendors. The blocking and deblocking of records is
done programmatically, as described earlier in Blocking Tape Records.
When writing a file, you must specify these values to correspond to the record size and
block size you will use when writing blocks to the file. When reading, the tape process
always uses the values for BLOCKLEN, RECLEN, and RECFORM that are written in
the tape label; the values in the DEFINE are not checked and don’t need to match the
values in the tape label.
The attributes are described as follows:
The BLOCKLEN attribute specifies the record-block size in bytes. When
appending to a tape file, you must specify the same value as contained in the file
label. If you are creating a new tape file, you must set the value to either an exact
multiple of the record length if you are using fixed-length records or a value equal
to the maximum record length if you are using unspecified-length records. The
following example sets the BLOCKLEN attribute:
ATTRIBUTE^NAME ':=' "BLOCKLEN "; !16 bytes
VALUE ':=' "2048" -> @S^PTR;
ERROR := DEFINESETATTR(ATTRIBUTE^NAME,
VALUE,
@S^PTR '-' @VALUE,
DEFAULT^NAMES);
IF ERROR > 0 THEN ...
The RECLEN attribute specifies the length of the record if you are using fixed-
length records. For appending, you must set this value to the corresponding value
in the file label. This attribute must not be specified if you are using variable-length
records.
ATTRIBUTE^NAME ':=' "RECLEN "; !16 bytes
VALUE ':=' "64" -> @S^PTR;
ERROR := DEFINESETATTR(ATTRIBUTE^NAME,
VALUE,
@S^PTR '-' @VALUE,
DEFAULT^NAMES);
IF ERROR > 0 THEN ...