# 9.2 CLOSE Statement

The CLOSE statement disconnects a file from a unit. It takes the following form:

                      { STATUS  }

    CLOSE ([UNIT=]u[, { DISPOSE } =p] [,ERR=s] [,IOSTAT=ios])

                      { DISP    }

u
  Is a logical unit number.
p
  Is a character expression that determines the disposition of the file. It can be any one of the following values:

  - 'SAVE' or 'KEEP': Retain the file after the unit closes.

  - 'DELETE': Delete the file.

  - 'PRINT': Submit the file to the line printer spooler and retain it.

  - 'PRINT/DELETE': Submit the file to the line printer spooler and then delete it.

  - 'SUBMIT': Submit the file to the batch job queue and retain it.

  - 'SUBMIT/DELETE': Submit the file to the batch job queue and then delete it.

  You can only use 'PRINT' and 'PRINT/DELETE' on sequential files.

  The default is 'DELETE' for scratch files. For all other files, the default is 'KEEP'.

s
  Is the label of an executable statement.
ios
  Is an integer scalar memory reference.

Rules and Behavior

CLOSE statement parameters can occur in any order. The UNIT keyword is optional if the unit specifier is the first parameter in the list.

The STATUS parameter has the same values as those listed for the DISPOSE keyword (see Section 9.6.9).

The disposition specified in a CLOSE statement supersedes the disposition 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. For example, the following statement closes the file on unit 1 and submits it for printing:

    CLOSE (UNIT=1, STATUS='PRINT')

The next statement closes the file on unit J and deletes it:

    CLOSE (UNIT=J, STATUS='DELETE', ERR=99)

Previous Page Next Page Table of Contents