COBOL Manual for TNS and TNS/R Programs
Tape Input and Output
HP COBOL Manual for TNS and TNS/R Programs—522555-006
27-5
Unlabeled Tape Files
Several Files on One Tape
To read or write more than one file on one tape, follow Step 1 through Step 5 under
Unlabeled Tape Files and then execute these steps:
1. Close the file with the CLOSE statement, specifying NO REWIND. The NO
REWIND phrase prevents the run-time routines from rewinding the tape, so that
you can read or write the file that immediately follows the file you just closed.
2. Reopen the file specifying NO REWIND (see Step 4 under Unlabeled Tape Files).
3. Read or write the file again (see Step 5 under Unlabeled Tape Files).
4. Close the file with the CLOSE statement. Do not use a NO REWIND phrase. Use a
LOCK phrase if the file was not dynamically assigned and you want to prevent the
tape from being reopened (the run-time tape routine ignores LOCK for a
dynamically assigned file).
Example 27-2 writes two files on one tape and then closes and locks the tape.
Example 27-2. Several Files on One Tape
...
ENVIRONMENT DIVISION.
...
INPUT-OUTPUT SECTION.
...
FILE-CONTROL
SELECT TAPE1 ASSIGN $DRIVE2
ORGANIZATION SEQUENTIAL
ACCESS MODE SEQUENTIAL.
...
PROCEDURE DIVISION.
...
*WRITE FIRST FILE
OPEN OUTPUT TAPE1 EXCLUSIVE
WRITE TAPE1 ...
CLOSE TAPE1 NO REWIND
*WRITE SECOND FILE
OPEN OUTPUT TAPE1 EXCLUSIVE NO REWIND
WRITE TAPE1 ...
CLOSE TAPE1 LOCK
...