CLOSE Statement

The CLOSE statement breaks the link between a logical file declared in the program and its associated physical file, which is the actual file data is sent to or from. For port files, it is used to close dialogs between processes.

<close statement>

── CLOSE ── ( ──<close file part>─┬──────────────────────┬─ ) ─────────┤
                                  └─ , ──<close options>─┘

<close file part>

──┬─<file designator>─┬───────────────────────────────────────┬────────┤
  │                   └─ [ ── SUBFILE ──<subfile index>── ] ──┤
  └─<task designator>── . ──<file-valued task attribute name>─┘

<subfile index>

──<arithmetic expression>──────────────────────────────────────────────┤

The CLOSE statement can be used as an arithmetic function. You cannot use a CLOSE statement inside another file I/O statement. For information about results returned, see the File Attributes Programming Reference Manual.

When no CLOSE option is specified, the CLOSE statement closes the file, depending on the kind of file, as follows:

Line Printer File

The printer is skipped to channel 1, an ending label is printed, and the printer is again skipped to channel 1. The file must be labeled.

Unlabeled Tape Output File

A double tape mark is written after the last block on the tape, and the tape is rewound.

Labeled Tape Output File

A tape mark is written after the last block on the tape; then an ending label is written followed by a double tape mark, and the tape is rewound.

Disk File

If the file is a temporary file, the disk space is returned to the system.

For all types of files, the I/O unit and the buffer areas are released to the system.

The <subfile index> syntax is used to specify the subfile to be closed.