Accessing Files Programmer's Guide (32650-90885)

104 Chapter6
Closing a File
How the File System Closes a File
You can specify the disposition of a file when it is opened when you use the
final
disposition option
or the
file equation option
of the HPFOPEN intrinsic, or the FILE
command. Both HPFOPEN options provides the same choices as the
disposition
parameter
of FCLOSE, except that you can change the disposition of a file when the file is opened (as
opposed to when the file is closed). For more information about HPFOPEN options, refer to
the MPE/iX Intrinsics Reference Manual.
NOTE
Even though you are allowed to specify a file's final disposition when the file
is opened, MPE/iX does not search the appropriate directory until you
attempt to close that file.
If a conflict occurs between the dispositions specified at file-open time and file-close time,
the disposition specification that has the lower positive-integer value takes precedence.
For example, if a disposition of temporary (
final disposition option
= 2) is specified by
HPFOPEN, and a disposition of permanent (
disposition
= 1) is specified by FCLOSE , the
disposition specified by FCLOSE takes precedence. Likewise, if there are conflicts between
the disposition specifications of multiple FCLOSE calls on the same file, the disposition
specification that has the lower positive-integer value takes precedence when the file is
finally closed.
If your program does not issue an FCLOSE intrinsic call on files that have been opened,
MPE/iX closes all files automatically when the program's process terminates. In this case,
MPE/iX closes all opened files with the same disposition they had before being opened.
New files are deleted; old files are saved and assigned to the domain in which they
belonged previously, either permanent or temporary; however, if you specified the file's
disposition when you opened it with HPFOPEN, that disposition takes effect.