The CLOSE statement disconnects a file from a unit. It takes the following form:
|'KEEP' or 'SAVE'||Retains the file after the unit closes.|
|'DELETE'||Deletes the file after the unit closes.1|
|'PRINT' 2||Submits the file to the line printer spooler, then retains it.|
|'PRINT/DELETE' 2||Submits the file to the line printer spooler, then deletes it.|
|'SUBMIT'||Forks a process to execute the file.|
|'SUBMIT/DELETE'||Forks a process to execute the file, then deletes the file after the fork is completed.|
1 Unless OPEN(READONLY) is in effect.
2 Use only on sequential files.
The default is 'DELETE' for scratch files and QuickWin applications (WNT, W9*). For all other files, the default is 'KEEP'.
Rules and Behavior
The CLOSE statement specifiers can appear in any order. An I/O unit must be specified, but the UNIT keyword is optional if the unit specifier is the first item in the I/O control list.
The status specified in the CLOSE statement supersedes the status specified in the OPEN statement, except that a file opened as a scratch file cannot be saved, printed, or submitted, and a file opened for read-only access cannot be deleted.
If a CLOSE statement is specified for a unit that is not open, it has no effect.
Consider the following statement:
CLOSE (UNIT=J, STATUS='DELETE', ERR=99)
This statement closes the file connected to unit J and deletes it. If an error occurs, control is transferred to the statement labeled 99.
For More Information: