QMSelectLeft(), QMSelectRight()

Top  Previous  Next

 

The QMSelectLeft() and QMSelectRight() functions traverse an alternate key index, creating a select list from the entry to the left or right of the last entry processed.

 

 

Format

 

VBQMSelectLeft(ByVal FileNo as Integer, ByVal IndexName as String, ByVal ListNo as Integer) as String

 

Cchar * QMSelectLeft(int FileNo, char * IndexName, int ListNo)

 

ObjStr = Session->SelectLeft(FileNo, IndexName, ListNo)

 

where

 

Varis the variable to receive the index key value associated with the returned list.

 

FileNois the file number returned by a previous QMOpen() call.

 

IndexNameis the name of the alternate key index to be used.

 

ListNois the select list number (0 to 10).

 

 

The QMSelectLeft() and QMSelectRight() functions construct a select list from the alternate key index entry to the left or right  of the one most recently returned by QMSelectIndex(), QMSelectLeft() or QMSelectRight(). The position of the scan can be set at the extreme left using QMSetLeft() or at the extreme right using QMSetRight().

 

These operations allow a program to find a specific value and then walk through successive values in the sorted data structure that makes up an alternate key index. The function returns the data value associated with the index entry found. The select list identified by ListNo is set to contain the records ids of the records that have this data value.

 

If QMSelectIndex() is used to locate a value that does not exist in the index, QMSelectLeft() will return a list of records for the value immediately before the non-existant one and QMSelectRight() will return a list of records for the value immediately after the non-existant one.

 

The QMStatus() function returns zero if the operation is successful, non-zero if it fails. Although other errors may occur, two useful status values are

3019

ER$AKNF

Specified index does not exist

3030

ER$EOF

No further items at end of index

 

The number of items in the select list can be established by using QMGetVar() to retrieve the @SELECTED variable immediately after the QMSelectIndex.