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.

Simple (Latent) Select

In BASIC+, a simple SELECT statement  (not an extended SELECT ... BY statement) does not directly produce a list of record keys for processing. Instead, the SELECT statement simply initializes variables in the system, indicating that a select condition is active.

In addition, the SELECT is passed to the filing system so it can perform any filing system-specific activity to initialize a select condition.  A filing system SELECT call returns a select mode with three possible values in the RECORD argument:

...

Select Mode

...

Meaning

...

0

...

No select list is active (disable the select)

...

1

...

Latent file select

...

2

...

Latent index select


 

 If a select condition is active, subsequent BASIC+ READNEXT statements will return record keys until the file has been exhausted. If no select list is active, a subsequent BASIC+ READNEXT statement will fall through its ELSE branch.

The select mode value is available to an BASIC+ program in the system variable @LIST.ACTIVE.  If the SELECT call fails for any reason, the RECORD argument is passed back false, indicating to the system that no select list is active.  @LIST.ACTIVE will also be set to false.

This BASIC+ program fragment illustrates the typical flow of a simple SELECT:

 

Code Block
SELECT FILE ; * establish "latent" select
DONE = 0
LOOP
  READNEXT @ID ELSE DONE = 1
  UNTIL DONE DO
    /* process the row */
REPEAT

ReadNext Processing

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.

...