ProvideX V8.20 > Language Reference > 2. Directives
55
CLOSE Directive
       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 label to transfer control to.
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, p.737. 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 and files owned by the object.
See Also
OPEN Open for Processing, p.231
BEGIN Reset Files and Variables, p.32
START Restart ProvideX, p.326
'WK' System Parameter, p.691
Examples
CLOSE (30)
OPEN (30)"PRINT_DEVICE"
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)