The CLOSE procedure closes an open file. Syntax: CLOSE( file_variable ,[[disposition]] ,[[user_action]] ,[[ERROR := error_recovery]] ) CLOSE( FILE_VARIABLE := file_variable [[,DISPOSITION := disposition]] [[,USER_ACTION := user_action]] [[,ERROR := error_recovery]] ) Except for the file variable parameter, all other parameters are optional. If the nonpositional parameter names are not used, as in the first syntax, the parameters must be in the order specified. If nonpositional parameter names are used, as in the second syntax, the parameters can be specified in any order.
1 – File Variable
The 'file_variable' is the name of the file variable associated with the file that VSI Pascal is to close.
2 – Disposition
The 'disposition' is a value that indicates what VSI Pascal should do with the file after you close the file. If SAVE is specified, the file is retained. If DELETE is specified, the file is deleted. If PRINT is specified, the file is printed on a line printer and is retained. If PRINT_DELETE is specified, the file is deleted after it is printed. If SUBMIT is specified, the file is submitted to a queue or placed in a background process and is retained. If SUBMIT_DELETE is specified, the file is deleted after being processed. SAVE is the default for external files. DELETE is the default for internal files. The disposition value in the CLOSE procedure supersedes a disposition value in the OPEN procedure.
3 – User Action
The 'user_action' is a routine name that VSI Pascal calls to close the file. You can use a user-action routine to close the file using environment-specific capabilities.
4 – Error Recovery
The 'error_recovery' specifies the action to be taken if an error occurs during execution of the routine. By default, after the first error, the error message is printed and execution is stopped. Execution of the CLOSE procedure causes the system to close the file and, if the file is internal, to delete it. Each file is automatically closed when control passes from the block in which it is declared. You cannot close a file that has not been opened (either explicitly by the OPEN procedure, or implicitly by the EXTEND, RESET, or REWRITE procedure). If you attempt to close a file that was never opened, an error occurs. The file can be in any mode (inspection, generation, or undefined) before the CLOSE procedure is called. Execution of CLOSE sets the mode to undefined.