This routine reads the next record in the sequence of records specified by the current key of reference. When a file is first opened, its key of reference is the primary key and the file is positioned so that the NEXT record is the first record in the file. The READ and START routines can change the current key of reference. The NEXT routine has two parameters, f, and record. F must be a valid file handle returned by OPEN. Record points to the area to hold the record read.
If this routine succeeds, RETURN-CODE is set to the size of the record read. If it fails, RETURN-CODE is set to zero and sets the current key of reference to the "undefined" state. However, if it fails due to the record being locked, the current key of reference is unchanged and the file pointer is set to the locked record (some file systems do not support this rule). Also, if it fails because it reached the end of the file, then the current key of reference is left unchanged and the file pointer is positioned so that a call to PREVIOUS returns the last record in the file.
The NEXT routine follows the same record locking rules as the READ routine.
If the record following the one read contains the same key value (in the current key of reference), then F-ERRNO is set to W-DUP-OK.