SSELECT


Use the SSELECT statement to create:

A numbered select list of record IDs in sorted order from a jBASE hashed file

A numbered select list of record IDs from a dynamic array

A select list of record IDs from a dynamic array is not in sorted order.

You can then access this select list by a subsequent READNEXT statement, which removes one record ID at a time from the list.

COMMAND SYNTAX

SSELECT [variable] [TO list.number] [ON ERROR statements]

SSELECTN [variable] [TO list.number] [ON ERROR statements]

SSELECTV [variable] TO list.variable [ON ERROR statements]

variable can specify a dynamic array or a file variable. If it specifies a dynamic array, the record IDs must be separated by field marks (ASCII 254). If variable specifies a file variable, the file variable must have previously been opened. If variable is not specified, the default file is assumed. If the file is neither accessible nor open, or if variable evaluates to null, the SSELECT statement fails and the program enters the debugger with a run-time error message.

The TO clause specifies the select list that is to be used.

list.number is an integer from 0 through 10. If no list.number is specified, select list 0 is used.

The record IDs of all the records in the file forms the list. The record IDs are listed in ascending order. Each record ID is one entry in the list.

Use the SSELECTV statement to store the select list in a named list variable instead of to a numbered select list. list.variable is an expression that evaluates to a valid variable name.

The ON ERROR Clause

The ON ERROR clause is optional in SSELECT statements. The ON ERROR clause lets you specify an alternative for program termination when a fatal error is encountered during processing of a SSELECT statement.

 

EXAMPLE

The following example opens the file SLIPPERS to the file variable DSCB, then creates an active sorted select list of record IDs. The READNEXT statement assigns the first record ID in the select list

to the variable @ID, then prints it.

OPEN '','SLIPPERS' ELSE PRINT "NOT OPEN"

SSELECT

READNEXT @ID THEN PRINT @ID

The output of this program is:

0001

INTERNATIONAL MODE

When using the SSELECT statement in International Mode, the statement will use the currently configured locale to determine the rules by which each string is considered less than or greater than the other for sort purposes.


jBC