Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

As a rule, MFS programmers do not need to concern themselves with these esoteric aspects of select list processing. In some cases -- for instance, in SI.MFS -- the MFS deliberately assumes control over specific tasks (in this case, returning sorted key lists). However, an MFS that does not concern the return of a sorted or reduced key list does not need to include logic for these tasks.

...


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.

Info
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.

READNEXT Direction

When a filing system READNEXT call is made, the status argument is used to pass to the filing system the direction of the READNEXT operation (ascending or descending). The filing system uses this direction in maintaining the select pointer. If the BASIC+ READNEXT operation designates the select list as descending, the select pointer is decremented with each filing system READNEXT operation, rather than being incremented for an ascending READNEXT.