Directives
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.

Note: If running with with the 'FF' System parameter (Fid Format) set to 2 (Thoroughbred), closing channel 0 will be treated the same as CLOSE (*)

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.


*Note* A CLOSE directive will delete a Memory file. See *MEMORY* Create & Use Memory File. When you CLOSE (chan), ProvideX returns all memory that was occupied by the Memory file to the system.


  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.


*Note* When executed within an object (in Object Oriented Programming), CLOSE (*) will close any standard local files as well as files owned by the object.


   
See Also OPEN Open a File for Processing
BEGIN Reset Files and Variables
START Restart ProvideX
'WK' System Parameter
   
Examples 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...

0500 LET CSTFILE=HFN; OPEN (CSTFILE)"CSTFILE"
0510 LET PRDFILE=UNT; OPEN (PRDFILE)"PRDFILE"
0520 LET ORDFILE=7; OPEN (ORDFILE)"ORDFILE"
0530 PRINT CSTFILE,PRDFILE,ORDFILE
0540 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)