COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

WRITE TAPE1 ...
CLOSE TAPE1 NO REWIND
*WRITE SECOND FILE
OPEN OUTPUT TAPE1 EXCLUSIVE NO REWIND
WRITE TAPE1 ...
CLOSE TAPE1 LOCK
...
One File on Several Tapes
To read or write one file that spans several tapes, follow Step 1 through Step 5 under Unlabeled
Tape Files and then execute these steps:
1. Close the file with the CLOSE statement, specifying REEL FOR REMOVAL (or UNIT FOR
REMOVAL). The REMOVAL phrase rewinds the tape for removal so that you can remove it
from the tape drive and replace it with the next tape.
2. Read or write the file again (see Step 5 under Unlabeled Tape Files).
3. Repeat Step 4 and Step 5 under Unlabeled Tape Files and Step 1 above for each tape that
contains part of the file.
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).
Mount Messages
When a run-time routine needs to have a reel of tape mounted, it sends a message to the process
home terminal.
Example 264 Mount Messages
For an input file:
Mount the next reel of fd-name = device-name in sequence
For an output file:
Mount the next reel of fd-name = device-name, with a write ring
Message sent to the home terminal:
Type return or $volume (or 'NO' to end input)
Respond to the message sent to the home terminal after the next tape reel is mounted. If the next
reel is ready on the device named in the mount message, press Return. If the next reel is ready on
a different tape device, type that device name (beginning with $) before you press Return.
If you do not want to continue with the next reel of tape, type “NO” in response to the message.
If the program is reading the tape, the next READ statement will discover an end of file.
For example, suppose that a file is stored on three tapes. Its COBOL file name is HUGEFILE. If
HP COBOL end-of-tape sequences were used when the tapes were created, HP COBOL automatically
asks for each reel; otherwise, you must read and then close each reel.
Example 265 assigns the COBOL file name HUGEFILE to the system file name $DRIVE2 (a name
that the system administrator assigned to a tape drive) and declares its organization and access
modes to be sequential. The first tape is on the tape drive $DRIVE2. The program opens HUGEFILE
for exclusive input, reads it, and closes it, rewinding it for removal. You replace the first tape with
the second tape, and the program reads it and closes it, rewinding it for removal. You replace the
second tape with the third tape, and the program reads, closes and locks it, having now read the
entire file.
Reading and Writing Tape Files 841