All KEYEDIO file management routines are contained in the SYSTEM/KEYEDIO library. Information about all the users of the file is also contained in the library stack. The library mechanism permits multiple users to access the same file and also provides links for all users of the same file to the same library stack. Your position in the file is maintained by a current record pointer that points to the fine table entry corresponding to your current record in the file.
When a file is opened, if the FILEORGANIZATION file attribute is equal to INDEXED or INDEXEDNOTRESTRICTED, the user program is linked to the SYSTEM/KEYEDIO library routines instead of to the normal FIBSTACK procedures. The KEYEDIO open routine performs certain checks to ensure file integrity. Refer to the File Attributes Programming Reference Manual for more information.
If the file is declared to be of type INDEXED, all keys declared when the file was created must be declared by your program each time the file is opened, and these keys must match exactly. If the file is of type INDEXEDNOTRESTRICTED, keys not known—not declared---by your program are still updated.
When the file is updated, recovery information is stored so that file integrity can be maintained in the event of abnormal termination. Because of the overhead involved, this information is not saved when the file is being created.
KEYEDIO files can be used by more than one user program at a time. Any number of user programs can be reading the file, but when one of the programs attempts to update—add, delete from, or rewrite—the file, other users of the file are locked out for the duration of the update transaction. This lockout feature permits more than one program to have the file open in update mode, while also preserving the integrity of the data. No mechanism exists for locking out other users for more than a single transaction; record level lockout is not provided.
The KEYEDIO library keeps track of the number of programs currently reading and writing to the file. For the file to be updated, both the reader and writer counts must equal zero (0). For the file to be read, the write count must equal zero (0).