guides:programming:programmers_reference_manual:simple_latent_select

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 ModeMeaning
0No select list is active (disable the select)
1Latent file select
2Latent 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 a 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:

SELECT FILE ; * establish "latent" select
DONE = 0
LOOP
  READNEXT @ID ELSE DONE = 1
  UNTIL DONE DO
    /* process the row */
REPEAT
  • guides/programming/programmers_reference_manual/simple_latent_select.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1