COBOL Manual for TNS and TNS/R Programs

HP COBOL Manual for TNS and TNS/R Programs522555-006
27-1
27 Tape Input and Output
HP COBOL batch programs must often read or write files that are on magnetic tape
(tape files).
Topics:
Reading and Writing Tape Files
Adding DEFINEs for Tape Files
Executing HP COBOL Programs That Use Tape Files
If you need further information on reading and writing tape files, see the Guardian
Programmers Guide.
If you want to archive disk files on magnetic tape, use the operating environment’s
BACKUP utility. To restore archived disk files from a tape back to a disk (which you
must do before an HP COBOL program can read them), use the operating
environment’s RESTORE utility. For information on the BACKUP and RESTORE
utilities, see the Guardian User’s Guide.
Reading and Writing Tape Files
An HP COBOL program can read and write unlabeled tape files, labeled tape files, and
tape files of types other than HP.
Topics:
Preventing Prereading
Saving Tape and Time
Unlabeled Tape Files
Labeled Tape Files
Tape Files of Types Other Than HP
By default, the shortest record an HP COBOL program can write to a tape file is 24
bytes. If you need shorter records, use the COBOL_SETMODE_ routine to set function
52 (see the Guardian User’s Guide).
Preventing Prereading
HP COBOL prereads tapes; that is, it initiates a new read operation after processing
the last (or only) record in a block. Prereading can overlap I-O with program
processing. If you do not want this to happen, verify that the records of a tape file will
not be preread by opening the file for timed I-O (include a TIME LIMITS phrase in the
OPEN statement or use the command PARAM WAITED-IO). For an explanation of
prereading file records, see Prereading File Records. You cannot give a tape file the
access mode I-O or the exclusion mode PROTECTED or SHARED.