Skip to main content

CLOSE Close File

Format

CLOSE {(*) | (chan)}[,(chan)...[,ERR=stmtref])]

Where:

*

Asterisk denotes "all OPEN local channels". CLOSE (*) resets all files then closes everything but channel 0 (unless the 'WK' parameter is set). This closes all open windows and purges graphical controls from the system.

chan

Channel or logical file number.

stmtref

Program line number or statement label to which to transfer control.

Description

Use the CLOSE directive to close a given logical file number. The memory used for buffers and control information is returned to the system. Once closed, the file (channel) number can be reused for a different file.

The ERR= branch will be taken should an error occur during the close. If the application tries to close an unopened file, an error will only be generated if an ERR= branch is provided. If an ERR= branch is not provided, the close is assumed to have occurred previously and no error is generated.

See Also

OPEN Open a File for Processing
BEGIN Reset Files and Variables
START Restart Session
'WK' Keep Window

Example

The following will open channel 30, print to it and then close it:

open (30)"PRINT_DEVICE"
print (30)
close (30)

Assuming the following logic:

CSTFILE=hfn;
open (CSTFILE)"CSTFILE"
PRDFILE=unt;
open (PRDFILE)"PRDFILE"
ORDFILE=7;
open (ORDFILE)"ORDFILE"
print CSTFILE,PRDFILE,ORDFILE
stop

->run
63 5 7

Either of the two statements below will close channels 63, 5 and 7. The second statement closes all other open local channels as well:

close (CSTFILE),(PRDFILE),(ORDFILE) ! Just closes channels 63,5,7
close (*) ! Closes ALL open file channels (i.e. 63,5,7 and 30)

Thoroughbred® is a registered trademark of Thoroughbred Software International Inc.