# OPENINDEX

Updated: 10/14/2021, 2:20:00 PM
Created: 10/14/2021, 2:20:00 PM
Last Updated By: mikes
Read Time: 1 minute(s)

Tags: file handling file indexing record handling

# Description

The OPENINDEX statement is used to open a particular index definition for a particular file. This index file variable can later be used with the SELECT statement. It takes the general form:

OPENINDEX filename,indexname TO indexvar {SETTING setvar} THEN|ELSE statements
1

Where:

  • filename should correspond to a valid file which has at least one index,
  • indexname should correspond to an index created for the filename,
  • indexvar is the variable that holds the descriptor for the index.

If the OPEN statement fails it will execute any statements associated with an ELSE clause. If the OPEN is successful it will execute any statements associated with a THEN clause. Note that the syntax requires either one or both of the THEN and ELSE clauses.

If the SETTING clause is specified and the open fails, setvar will be set to one of be set to one of these values.

An example of use is as:

OPENINDEX "CUSTOMER","IXLASTNAME" TO custlastname.ix SETTING errval ELSE
    CRT "OPENINDEX failed for file CUSTOMER, index IXLASTNAME"
    ABORT
END
1
2
3
4

Go back to jBASE BASIC

Go back to Programmers' Reference Guide