COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
• When the block size is specified in characters, it is a multiple of the number of characters in
the logical record size. Also, when a RECORD CONTAINS clause extends the record size,
the block size expressed is a multiple of the number of characters in that specified record size.
• The file description entry does not have a LINAGE or ALTERNATE RECORD KEY clause.
On NonStop systems, physical record (block) sizes for tapes range from 24 through 32,767 bytes.
The recommended maximum tape block sizes for application programs are:
Block Size (bytes)Density (bytes per inch)
4,096800
8,1921,600
32,7676,250
For further information on the BLOCK CONTAINS clause, see BLOCK CONTAINS Clause (page 162).
Unlabeled Tape Files
An unlabeled tape file is a tape file that does not have standard ANSI or IBM labels.
If an 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, an
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
COBOL_ASSIGN_ routine to establish the system file name of the tape at run time (see
#DYNAMIC (page 835)) and go to Step 4.
3. If you used a DEFINE name in Step 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.
Effectfile-specification
Opens the tape for input so you can read itINPUT
Opens the tape for output so you can write it, starting with its first recordOUTPUT
Opens the tape for extension so you can write it, starting immediately after
its last record
EXTEND
(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.
Reading and Writing Tape Files 839










