The program environment determines whether fsetpos() is executed for a BS2000 or POSIX file. BS2000
fsetpos() can be used on binary files (SAM in binary mode, PAM, INCORE) and text files (SAM in text mode, ISAM). fsetpos() cannot be used on system files (SYSDTA, SYSLST, SYSOUT). A successful call to the fsetpos() function deletes the EOF flag of the file and cancels all the effects of the preceding ungetc calls for that file. If new records are written to a text file that was opened in the write or append mode and an
fsetpos call is issued, any data that may still be in the buffer is first written to the file and terminated with a newline character (\n). Exception for ANSI functionality: If the data of an ISAM file in the buffer does not end in a newline character, fseetpos() does not insert a change of line (or record). In other words, the data is not automatically terminated with a newline character when it is written from the buffer. Subsequent data extends the record in the file. Consequently, when an ISAM file is read, only the newline characters that were explicitly written by the program are read in. After positioning, the next operation may be either a read or write operation. For ISAM files, the function pair fgetpos() /fsetpos() is far more efficient than the comparable function pair ftell() /fseek() . In the case of record I/O in ISAM files with key duplication, fsetpos() cannot be used to position on the second or higher record of a group with identical keys. This can only be done by sequential reading or deletion. fsetpos() can only be used to position on the first record or after the last record of such a group. (End) |