Friday, September 4, 2009

The CLOSE Statement
Syntax
Format
CLOSE { file-name-1 [ { REEL
UNIT }[ WITH NO REWIND
FOR REMOVAL ] ]} ...
WITH { NO REWIND
LOCK }
Description
The CLOSE statement is used to terminate processing on a file. All files should be closed before exiting a program. The optional clauses perform the following functions:
" REEL and UNIT are interchangeable and are only useful for multiunit files, such as multi-reel tape files. Closing the reel doesn't actually close the file, just the current volume.
" FOR REMOVAL is only useful for files residing on removable media. Closing for removal will cause the volume to be dismounted.
" ITH NO REWIND is only useful for files residing on magnetic tape. Closing with no rewind terminates access to the file without automatically rewinding the tape.
" WITH LOCK prevents the file from being re-opened during the execution of the program.
Tips
1. If there is a file status associated with the file, it will be set after the CLOSE is execute to indicate the result of the CLOSE. A value of "00" means successful.
2. If you omit the CLOSE statement, files will be closed automatically when you exit the program, but this considered bad form.
3. A closed file must be re-opened if it is necessary to access it again.
4. If a file is not needed for part of the duration of a program, closing it will free the system resources it occupies.