Skip to content

CLOSE

End I/O Channel Operations

This directive terminates operation on a designated input/output channel and removes the effects of any EXTRACT or LOCK on that input/output channel.

CLOSE (channel [,ERR=line-ref|,ERC=error-code])
channel
is an integer from 1 through 32764, which specifies the channel of an OPEN file or device; or 0, which specifies all channels except 0.
line-ref
is the program line number or label to branch to if this directive produces an error.
error-code
is a programmer-defined error code. Valid values are positive or negative whole numbers.

Channel values above 14 are generally available starting with release level 8.0.

Channel 0 is reserved for the terminal and keyboard of the individual task or the inter-task communication channel for ghost tasks (see the section on Ghost Tasks in the chapter on Program Control in Volume I). Beginning with release level 8.0, CLOSE (0) results in CLOSEing all OPEN files on channels 1 through 32764.

A file or device remains OPEN, and its assigned input/output channel is unavailable for other use until it is CLOSEd by the BEGIN, CLOSE, END, or STOP directives.

The CLOSE directive automatically UNLOCKs a file that has been LOCKed by the current task and releases any EXTRACTed records.

An OPEN printer device is unavailable to other tasks until CLOSEd. An OPEN file can be accessed by other tasks, unless that file has been reserved for this task by the LOCK directive.

All OPEN files and devices in a task are CLOSEd by the BEGIN, CLOSE, END, or STOP directives.

CLOSEing an input/output channel that has already been CLOSEd does not cause an error.

If channel is negative, non-integer, or greater than 32764, an ERR=41 results.

For information on how to use the CLOSE directive to finish a DDE conversation when you use the Thoroughbred Environment under Microsoft Windows, please refer to the description of the OPEN directive.

CLOSE (1)

closes the file or device OPEN on input/output channel 1.

CLOSE (CHANNEL_NUMBER,ERR=7999)

If CHANNEL_NUMBER = 1, has the same effect as the first example and branches to program line number or label 7999 if CHANNEL_NUMBER contained a negative number, a non-integer, or a number greater than 32764.

LOCK, OPEN, and UNLOCK directives

From the Thoroughbred Basic Language Reference, Volume I: A–E, version 8.9.1. Open this page in the PDF