HPlogo Accessing Files Programmer's Guide > Chapter 6 Closing a File

How the File System Closes a File

MPE documents

Complete PDF
Table of Contents
Index

E0300 Edition 6 ♥
E0692 Edition 5

You terminate access to a file from your program with the FCLOSE intrinsic. The FCLOSE intrinsic applies to both disk and device files. FCLOSE also deallocates the device on which the file resides; however, if your program has several concurrent HPFOPEN/FOPEN calls issued to the same file, the device is not deallocated until the last "nested" FCLOSE intrinsic is executed.

You can use the FCLOSE intrinsic to specify (or change) the disposition of a disk or a magnetic tape file when it is closed. The disposition of a disk or magnetic tape file can be new, temporary, or permanent. If you do not change the disposition of a new file when it is closed, the file and its contents are deleted from the system when the file is closed using FCLOSE.

You can change the disposition of a new file to be either temporary or permanent. A file closed with a temporary disposition is closed as a temporary file. It is deleted from the system when your job/session is terminated. A file closed with a permanent disposition is closed and saved as a permanent file. It remains in the system domain after your job/session ends, and until you purge it.

When you close a file with either a temporary or permanent disposition, MPE/iX conducts a search:
  • If the file is to be closed as a temporary file, the job file domain is searched.

  • If the file is to be closed as a permanent file, the system file domain is searched.

You are not allowed to have duplicate file names in the same domain. If MPE/iX finds a file of the same name in the searched directory, the file is not closed, and the FCLOSE intrinsic returns an error condition.

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.




Chapter 6 Closing a File


Closing a Disk File