INDEX (declare static file access index)

Top  Previous  Next

 

label

INDEX([-/+][field],...,[-/+][field]) [,NAME( )] [,NOCASE] [,OPT]

label

The label of the INDEX (PROP:Label).

INDEX

Declares a static index into the data file.

-/+

The - (minus sign) preceding an index component field specifies descending order for that component. If omitted, or + (plus sign) the component is sorted in ascending order.

field

The label of a field in the RECORD structure of the FILE in which the INDEX is declared. The field is an index component. Fields declared with the DIM attribute (arrays) may not be used as index components.

NAME

Specifies the disk file specification for the INDEX (PROP:NAME).

OPT

Excludes those records with null values (zero or blank) in all index component fields (PROP:OPT).

NOCASE

Specifies case insensitive sort order (PROP:NOCASE).

 

INDEX declares a "static key" for a FILE structure. An INDEX is updated only by the BUILD statement. It is used to access records in a different logical order than the "physical order" of the file. An INDEX may be used for either sequential file processing or direct random access.

An INDEX always allows duplicate entries. An INDEX may have more than one component field. The order of the components determines the sort sequence of the index. The first component is the most general, and the last component is the most specific. Generally, a data file may have up to 255 indexes (and/or keys) and each index may be up to 255 bytes, but the exact numbers are file driver dependent.

An INDEX declared without a field creates a "dynamic index." A dynamic index may use any field (or fields) in the RECORD as components (except arrays). The component fields of a dynamic index are defined at run time in the second parameter of the BUILD statement. The same dynamic index declaration may be built and re-built using different components each time.

Example:

Names   FILE,DRIVER('TopSpeed'),PRE(Nam)

NameNdx    INDEX(Nam:Name),NOCASE     !Declare the name index

NbrNdx     INDEX(Nam:Number),OPT      !Declare the number index

DynamicNdx INDEX()                    !Declare a dynamic index

Rec        RECORD

Name        STRING(20)

Number      SHORT

          END

       END

See Also:

SET

GET

KEY

BUILD