Simplified File IO
A feature of the 8.4 release of PL/B dramatically simplifies writing, updating, and deleting information in ISAM and AAM files. In the past, programmers encountered many problems due to incorrectly constructed keys. If multiple indices were used, the correct generation and insertion of all the keys was a significant task. The same problem existed for deletions. Additionally, if duplicate keys were used, logic was required to locate the correct record for deletion. Finally, for updates, the user was required to check each key field for changes and perform the appropriate DELETEK and INSERT operations. Adding AAM indexes even made the problem worse.
Enter the Simplified File I/O System. The first step is to allow ISAM WRITE statements to calculate the keys internally instead of being specified. This is how an AAM WRITE is performed. AAM looks at the record and generates the proper keys based on the data. Simplified File IO allows ISAM to do the same thing. The programmer simply writes the record and the runtime calculates the keys from the data.
The next step is a new FILELIST statement that associates all of the index files that relate to the same text file. Open all of the IFILEs and AFILEs as you normally do and you are ready to go. Then to perform a WRITE, you simply WRITE to the FILELIST label instead of performing a WRITE to one of the indices and INSERTs to all of the other indices. The data is written to the text file and ALL of the indices are updated with the correct keys for each file. The indices can be ISAM or AAM or mixed. For an UPDATE, you simply UPDATE to the FILELIST label and the data is updated. All keys are matched to the data to see if they changed. If so, the appropriate DELETEK/INSERT operation is done for ISAM files or the AAM keys are changed as needed also. For a DELETE, you again DELETE to the FILELIST label and the data is deleted from the text file. All keys that correspond to the data record are deleted from the various indices. The problem of deleting the correct information when duplicate keys are allowed is handled without you having to do anything.
Simplified File I/O System is available for both Linux and Windows versions of PL/B.
See Also: Disk I/O Instructions
![]() |