TAPE - tape I/O in B.

The B batch library is organized to make I/O as device-independent as possible. A tape may be specified on a $TAPE card, as in

$   tape    tp,x1d,,12345,,filename,,den16

which specifies a tape labelled "12345" as file code "tp" (see the control cards reference manual for a detailed format description). This file may then be accessed by an open of FC*TP, (e.g. unit = open("fc**tp", "r"); ) and treated as any other file; label verification is handled by the I/O library.

Note that the sample card above also specifies a file name. This field is ignored by the I/O library, but appears in $PALC's console messages; it is frequently used to provide further identification information for the operator.

A tape may contain an arbitrary number of files, and a file may be spread over an arbitrary number of sequential reels. However, unless otherwise specified, a tape will be rewound on open. If you specify the name of a particular file on the tape by FC*TP/name, that name will be used in the label of the file that is being written or will be checked against the label of the file at the current position. The tape is not searched for a file of that name. The tape must be positioned already.

OPEN action "h" may be used to specify that a tape is not to be rewound on open. This action must be used if you wish to access anything other than the first file on the tape. Action "g" (no mnemonic significance) is used to specify that the tape is unlabelled, so labels are not checked or written.

At the end of a file on read or write, the tape is positioned to read or write the next file on the tape. If you are writing a tape and the end of reel is encountered, a normal GCOS volume switch to a continuation reel is performed. If you are reading back such a reel and the tape is labelled, a normal volume switch to the next reel is also performed. However, if the tape is not labelled, an EOF status will be returned to the user. It is up to your program to know whether or not there is a continuation reel. Note that GCOS has actually written an EOV label but the B library will not look for it since there is no assurance that this is not a stranger tape and the label is absent.

Notes:

Append action is not supported for tapes.

The seek and tell functions (e.g. FSEEK and FTELL) do not work on tape units.

The REWIND function will rewind a tape to load point. If you need to write on a tape and then read the data back at some point in the same program, you should always call CLOSE and then reopen the tape file code for reading.

The function READ will read binary records from a tape using the "read tape binary" (RTB) instruction. The function WRITE will write binary records on a tape using the "write tape binary" (WTB) instruction.

The TP.RD9 function reads from tape using the RT9 instruction and the TP.WR9 function writes to tape using the WT9 instruction. You may use the TP.CMD function to issue MME GEINOS tape commands such as REW_, WEOF_, and so on.

On a labelled tape, READ will return a status of -017 when it encounters the EOF label. EOV labels will cause normal volume switches to the continuation reel. For an unlabelled tape, a status of -017 will be returned if a standard EOF mark is encountered. Status -04 will be returned for non-standard EOF's if the caller has asked for error recovery.

If a labelled tape is positioned after the last file on a tape, (i.e. at the partial label), and if OPEN is called with "f" action (and presumably "h"), then OPEN will return a fake status of -055 (octal). This may be used by a program that wants to process all the files of a multi-file tape.

Copyright © 1996, Thinkage Ltd.