Accessing Files Programmer's Guide
> Chapter 7 Record Selection and Data TransferRecord Selection |
||||||||||||||||||||||||||||||||||
|
Sequential accessWhen you use this method of record selection, you assume that the record pointer is already where you want it. You transfer your data using the FREAD or FWRITE intrinsic, and the record pointer is automatically set to the beginning of the next record at the end of each read or write; for this reason, this method is also called serial record selection. For fixed-length and undefined-length record files, the file system updates the record pointer by adding the uniform record length to the pointer after you read or write a record; for variable-length record files, the file system takes the byte count from the record being transferred plus some bytes required for overhead, and adds that to the record pointer, resulting in a pointer to the next record. Random accessIf the record pointer is not indicating the location that you want, you can use the random access method to move the pointer and begin your transfer wherever that you like; for this reason, this method is also called controlled record selection. It is possible to access specific records in a disk file with the FREADDIR and FWRITEDIR intrinsics. The record number to be read or written is specified as one of the parameters in the FREADDIR or FWRITEDIR intrinsic call. Following the read or write operation, the record pointer is set to the next record, as in the default case. Note that FREADDIR and FWRITEDIR may be issued only for a disk file composed of fixed-length or undefined-length records. Update accessTo update a logical record of a disk file, you use the FUPDATE intrinsic. The FUPDATE intrinsic affects the last logical record (or block for NOBUF files) accessed by any intrinsic call for the file named and writes information from a buffer in the stack into this record. Following the update operation, the record pointer is set to indicate the next record position. The record number need not be supplied in the FUPDATE intrinsic call; FUPDATE automatically updates the last record referenced in any intrinsic call. Note that the file system assumes the record to be updated has just been accessed in some way. You must open the file containing the record to be updated with the access type option parameter of the HPFOPEN/FOPEN call set to update access. In addition, the file must not contain variable-length records. Table 7-1 Intrinsics for Data Transfer
RIO accessRIO is an access method that permits individual file records to be deactivated. These inactive records retain their relative position within the file. RIO access is intended for use primarily by COBOL programs; however, you can access these files by programs written in any language. You create an RIO file using the file type option parameter of HPFOPEN/FOPEN. RIO files may be accessed in two ways, RIO access and non-RIO access. RIO access ignores the inactive records when the file is read sequentially using the FREAD intrinsic, and these records are transparent to you; however, they can be read by random access using FREADDIR. They may be overwritten both sequentially and randomly using FWRITE, FWRITEDIR, or FUPDATE. With non-RIO access, the internal structure of RIO blocks is transparent.
|