Once a select condition is established (select mode is true), the system can use a READNEXT command to return record keys from the select list. In BASIC+, READNEXT is used to return a single key from the select list.  In a filing system, however, a READNEXT call returns an entire block of keys.

When a READNEXT operation is being performed at the BASIC+ level, requests for record keys are processed by the READNEXT processor. The processor maintains a system list variable (cursor) for currently active keys. When a program first executes an BASIC+ READNEXT, this list variable is typically empty.

If the list variable is empty, the READNEXT processor generates a filing system READNEXT operation. The filing system READNEXT returns a block of keys, which the processor stores in the system list variable.

The READNEXT processor satisfies requests for individual record keys from this list variable. When the READNEXT processor reaches the end of the list of keys in the list variable, the READNEXT processor generates another BFS READNEXT call. The filing system READNEXT call returns the next block of keys, which replaces the keys in the system list variable. A BASIC+ READNEXT command may thus execute many times before causing the READNEXT processor to execute a filing system READNEXT operation.

This cycle of filling the list variable, exhausting it, and generating a new filing system READNEXT operation continues until the filing system READNEXT indicates that there are no more blocks of keys in the file. At that point, the filing system READNEXT sets the status argument to false. This causes the BASIC+ READNEXT operation to fall through its ELSE logic.

In order to track its progress through the file, the filing system READNEXT operation maintains a select pointer. This is a type of handle that contains the information that the filing system READNEXT requires in order to fetch the next block of keys properly. A simple select pointer might contain a pointer to the next block or group of keys to be fetched. As each filing system READNEXT operation is called, the select pointer is incremented.

An MFS should not disturb a select pointer for which it is not responsible. Doing so can cause severe errors in the key blocks returned by a filing system READNEXT operation, or can result in logical read errors in the file.
  • No labels