COBOL Manual for TNS and TNS/R Programs
Tape Input and Output
HP COBOL Manual for TNS and TNS/R Programs—522555-006
27-3
Unlabeled Tape Files
For further information on the BLOCK CONTAINS clause, see BLOCK CONTAINS
Clause.
Unlabeled Tape Files
An unlabeled tape file is a tape file that does not have standard ANSI or IBM labels.
If a HP COBOL program creates a tape file, the tape file is unlabeled, and any other
HP COBOL program can easily read or write it. If a system that is not an HP system
creates a tape file, a HP COBOL program can still read it, but might encounter features
that are not HP features.
The first five steps for reading or writing an unlabeled tape file are the same:
1. In the file-control entry:
a. Assign the COBOL file name of the tape to either:
•
The device name of the tape drive that holds the tape that you want to read
or write (established when the system was configured)
•
A DEFINE name
b. In the ORGANIZATION clause, declare SEQUENTIAL organization.
c. In the ACCESS MODE clause, declare SEQUENTIAL access.
2. If you used dynamic file assignment in Step 1a, then in the Procedure Division, use
the COBOLASSIGN or COBOL_ASSIGN_ routine to establish the system file
name of the tape at run time (see #DYNAMIC) and go to Step 4.
3. If you used a DEFINE name inStep 1a, add the appropriate DEFINE before
executing your program (see Adding DEFINEs for Tape Files) and go to Step 4.
4. Open the file with the appropriate file-specification in the OPEN
statement. To prevent prereading of file records, include a TIME LIMITS phrase in
the OPEN statement or use the command PARAM WAITED-IO.
(You cannot open a tape with the keyword I-O, which allows both input and output.)
5. If you opened the file for input, read it with the READ statement; if you opened it for
output or extension, write it with the WRITE statement.
After Step 5, the instructions depend on whether you are reading or writing one file on
one tape, several files on one tape, or one file that spans several tapes.
file-specification Effect
INPUT Opens the tape for input so you can read it
OUTPUT Opens the tape for output so you can write it, starting with its first
record
EXTEND Opens the tape for extension so you can write it, starting
immediately after its last record