Closes a file or a device.
||Optional A postconditional expression.
||The device to be closed.
||Optional One or more parameters used to set characteristics of the device. A single parameter may be specified as a quoted string: CLOSE device:"D". Multiple parameters must be specified enclosed by parentheses and separated by colons.
releases ownership of the specified device, optionally sets a parameter
, and returns it to the pool of available devices.
If the process does not own the specified device, or if the specified device is not open or does not exist, Caché ignores CLOSE
and returns without issuing an error.
An optional postconditional expression. Caché executes the CLOSE
command if the postconditional expression is true (evaluates to a nonzero numeric value). Caché does not execute the command if the postconditional expression is false (evaluates to zero). For further details, refer to Command Postconditional Expressions
in Using Caché ObjectScript
The device to be closed. A device
can be a physical device, a TCP connection, or a sequential file. Specify the same device ID (mnemonic or number) as specified on the corresponding OPEN
command. For more information on specifying device IDs, refer to the OPEN
You can specify a single device ID or as a comma-separated list of device IDs. CLOSE
closes all of the listed devices that the process currently has open. It ignores any listed devices that do not exist or are not currently open by this process.
The device ID of the current device is contained in the $IO
A parameter or a colon-separated list of parameters used when closing the specified device. Parameter codes are not case-sensitive. Multiple parameters must be enclosed with parentheses and separated by colons.
The available parameter values are as follows:
||Closes and deletes a sequential file. Can also be specified as /DEL, /DEL=1, /DELETE, or /DELETE=1.
||Closes and renames a sequential file. Can also be specified as /REN=newname or /RENAME=newname.
||Closes at the Caché level but not at the operating system level. Used only on non-Windows systems.
If the specified parameter
is not valid, CLOSE
still closes the device.
In the following UNIX® example, the CLOSE
command closes device C (/dev/tty02), but only if it is not the current device. The postconditional uses the $IO special variable to check for the current device.
Acquiring Ownership of a Device
A process acquires ownership of a device with the OPEN
command and makes it active with the USE
command. If the closed device is the active (that is, current) device, the default I/O device becomes the current device. (The default I/O device is established at login.) When a process is terminated (for example, after a HALT
), all its opened devices are automatically closed and returned to the system.
If the process’s default device is closed, any subsequent output (such as error messages) to that device causes the process to hang. In this case, you must explicitly reopen the default device.