Function
For sequential file organization: The CLOSE statement terminates the processing of input/output reels, units and files, with optional rewind and/or lock functions.
For relative and indexed file organization: The CLOSE statement terminates the processing of files, with optional lock functions.
Format 1 for sequential file organization
CLOSE {file-name [ [{ REEL | UNIT }] [FOR REMOVAL]
| WITH { NO REWIND | LOCK }
]
} ...
Format 2 for relative and indexed file organization
CLOSE {file-name-1 [WITH LOCK]}...
Syntax rules
The files referenced in the CLOSE statement need not have the same organization or access type.
The terms 'REEL' and 'UNIT' are synonymous and completely interchangeable within a CLOSE statement. The handling of sequential mass storage files is logically equivalent to the handling of files on magnetic tape or similar sequential media.
In the case of line sequential files only the specification WITH LOCK is permitted.
General rules
A CLOSE statement may be issued only for a file which is open.
The meanings of the options in the CLOSE statement are given below:
REEL
The current tape reel is to be closed.
UNIT
The current mass-storage unit is to be closed.
NO REWIND
No repositioning to the beginning of the reel is to be performed after a tape file is closed.
LOCK
The file cannot be reopened in the same program run.
REMOVAL
The current reel of a magnetic tape file is to be unloaded.
In order to show the effect of various CLOSE statements as applied to various storage media, all input/output files are divided into the following categories:
UNIT RECORD volume file (unit record file):
a file assigned to an input or output medium for which the concepts rewinding, units, and reels have no meaning.Sequential single-volume file:
a sequential file that is entirely contained on one volume. There may be more than one file on this volume.Sequential multi-volume file:
a sequential file contained on more than one volume.
The results of executing each CLOSE statement for each type of file are summarized in the following table:
CLOSE statement
File type
Sequentially organized files
Relative/indexed
Unit record
Sequential single-volume
Sequential multi-volume
Single-/multi- volume
CLOSE
C
C, G
C, G, A
C
CLOSE WITH LOCK
C, E
C,G,E
C, G, E, A
C,E
CLOSE WITH NOREWIND
C, H
C, B
C, B, A
—
CLOSE FOR REMOVAL
C, H
G, D
F, G, D
— CLOSE
REEL/UNITJ
F, G
F, G
— CLOSE REEL/UNIT
FOR REMOVALJ
F, G, D
F, G, D
— Table 26: Relationship between types of files and the formats of the CLOSE statement
The definitions of the symbols used in the table are given below. When the definition of the symbol depends on whether the file is an input or output file, alternate definitions are given; otherwise, a definition applies to files opened as INPUT, OUTPUT and I-O.
A
Previous volumes unaffected
All volumes of the file processed prior to the current volume were processed according to standard volume switching procedures, except those volumes controlled by a prior CLOSE REEL/UNIT statement.
B
No rewind of current reel
The current volume is positioned at the logical end of the file on the volume.
C
Standard close file
For files opened with the INPUT or I-O phrase:
if the file is positioned at its end and a LABEL RECORDS clause was supplied, then (if a USE procedure is present) the standard trailer label procedure and user trailer label procedure are executed. The order in which these two routines are executed is specified by the USE procedure. The standard system closing procedures are then performed.
If the file is positioned at its end, but a LABEL RECORDS clause was not supplied, then only the standard system closing procedures are performed.
If the file is positioned other than at its end, only the standard system closing proce-dures are performed. Even if USE procedures are supplied, no label processing will take place in this case. (An INPUT or I-O file is considered to be at its end if the imperative statement in the AT END phrase of the READ statement, if entered, has been executed, and no CLOSE statement has been executed.)
For files opened with the OUTPUT phrase:
if a LABEL RECORDS clause was specified for this file, the standard ending label procedures and the user ending label procedures (provided such were specified by a USE procedure) are performed. The order in which these two procedures are executed is defined by the USE statement. The standard system closing procedures are then performed.
If label records are not specified for the file, only the standard system closing proce-dures are performed.
D
Unload current reel
The REMOVAL option, when specified, causes the current reel of a magnetic tape file to be unloaded. Further processing of the file requires an appropriate continuation reel. After executing a CLOSE statement without the REEL/UNIT phrase specified, and an OPEN statement for this file, this reel may be processed again.
E
Standard file lock
If the LOCK phrase is used, the file cannot be reopened in the same program run.
F
Standard close volume
The following operations are performed for files opened with the INPUT or I-O phrase:
When the current volume is the last or only volume for the file:
Disk storage files
Processing of the current data block is terminated. The next READ statement makes the first record of the following data block available.
Tape files
Processing of the reel is terminated. The next READ statement leads to an at end condition.
When other volumes exist for the file:
Volume swapping.
USE procedures for processing standard and user header labels (if specified by a USE statement). The order in which these procedures are executed is defined by the USE statement.
The next record on the new volume is made available for the subsequent read operation.
For files opened as OUTPUT, the following operations are carried out:
Disk storage files
Processing of the current data block is terminated. The next WRITE statement creates a new data block.
Tape files
Standard and user trailer label procedures (if specified by a USE statement). The order in which these procedures are executed is defined by the USE statement.
Volume swapping.
Standard and user header label procedures (if specified by a USE statement). The order in which these procedures are executed is defined by the USE statement.
G
Rewind
The current volume is positioned at its beginning (for a magnetic tape file, this is the beginning of the reel; for disk storage files, this is the beginning of the file concerned).H
I/O status 07 is set.
The optional phrases are ignored.
J
I/O status 07 is set.
The CLOSE statement is ignored.
The execution of a CLOSE statement causes the contents of the data item specified in the FILE STATUS clause (if such a clause exists) to be updated (see section "FILE STATUS clause").
After successful execution of a CLOSE statement, the record area assigned to the file is no longer accessible. The unsuccessful execution of such a CLOSE statement leaves the availability of the record area undefined.
If an optional input file does not exist, no end-of-file processing and no reel/volume processing is executed.
If more than one file-name has been specified, the effect is the same as if a separate CLOSE statement had been written for each file-name.
All files that are still open on completion of a task are closed.