Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 13
Writing Tape Records
256 bytes are transferred into SBUFFER, 256 is returned in COUNT^READ, and the
condition code is set to CCL. The call to FILE_GETINFO_ returns error number 21
(illegal count specified). After the read operation, the tape is positioned immediately
before the beginning of the next record block on tape.
Writing Tape Records
Use the WRITE[X] procedure to write record blocks to magnetic tape. Each WRITE[X]
procedure call writes one record block to the tape. The WRITE[X] procedure is
typically used when sequentially appending information on the tape.
The following procedure call writes one record block to tape:
WCOUNT := 2048;
CALL WRITEX(TAPE^NUM,
TAPE^BUF,
WCOUNT,
COUNT^WRITTEN);
IF <> THEN ...
Here, 2048 bytes are written to tape. The value 2048 is returned in the
COUNT^WRITTEN variable.
Normally, the file system pads write operations of fewer than 24 bytes with null (0)
characters. The number of bytes of null characters is 24 minus the write count
specified in the WRITE[X] procedure call. Therefore the smallest record block that can
be written to a tape is 24 bytes.
Using SETMODE function 52, an application can either disallow writing record blocks
that are shorter than 24 bytes, allow records that are shorter than 24 bytes but pad
them with null characters, or allow records that are shorter than 24 bytes without
padding. If writing record blocks shorter than 24 bytes without padding is allowed, then
the limit on the shortest record size allowed is controller-dependent.
The following example disallows writing record blocks that are shorter than 24 bytes:
LITERAL SHORT^WRITE^MODE = 52,
NO^SHORT^WRITES = 1;
.
.
CALL SETMODE(TAPE^NUM,
SHORT^WRITE^MODE,
NO^SHORT^WRITES);
IF <> THEN ...
If an application disallows writing short record blocks but later tries to write a record
block of fewer than 24 bytes, the WRITE[X] procedure returns error 21.
When the application has finished writing record blocks to an unlabeled tape, the
application should indicate the end of the tape file by writing an EOF mark to the tape.
You do this by calling CONTROL operation 2:
LITERAL WRITE^EOF = 2;
.