Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 11
Reading and Writing Tape Records
Use CONTROL operation 5 to rewind the tape to the BOT sticker, leaving the tape
online. This procedure call does not wait for completion.
LITERAL REWIND^ONLINE = 5;
.
.
CALL CONTROL(TAPE^NUM,
REWIND^ONLINE);
IF <> THEN ...
Finally, CONTROL operation 6 rewinds the tape to BOT and leaves the tape online.
Your program waits for the operation to finish.
LITERAL REWIND^AND^WAIT = 6;
.
.
CALL CONTROL(TAPE^NUM,
REWIND^AND^WAIT);
IF <> THEN ...
Reading and Writing Tape Records
Application programs read and write tape records by calling the READ[X] and
WRITE[X] procedures. A record is the amount of data that is read by a single read
operation or written by a single write operation. A record block can be as large as
57,344 bytes depending on the particular tape device. The shortest record block is
usually 24 bytes, but that can be changed using SETMODE function 52 for some
controllers, as described later.
Before performing either read or write operations, the tape file must already be open.
The way you do this depends on whether you are accessing a labeled or unlabeled
tape. Refer to Working With Standard Labeled Tapes later in this section for
information on how to open a labeled tape file and to Working With Unlabeled Tapes,
also later in this section, for details on how to open a tape file for unlabeled tape
access.
The following paragraphs describe how to read and write tape records.
Reading Tape Records
Use the READ[X] procedure to read record blocks from magnetic tape. One READ[X]
procedure call reads one record block from the tape. Whenever a read operation is
issued against the tape file, the tape spaces forward one record block, even if the read
is for zero bytes.
An example shows how to read from a magnetic tape. Consider a file on tape that
consists of three record blocks, where each record block contains 1024 bytes.
Repeated reads of 2048 bytes are executed as follows:
LITERAL EOF = 1;
INT LOOP := 1;
.