QMSelectLeft and QMSelectRight

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. They are analogous to the QMBasic SELECTLEFT and SELECTRIGHT statements.



The function arguments are:


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 indexed 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-existent one and QMSelectRight() will return a list of records for the value immediately after the non-existent 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



Specified index does not exist



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.


The example program fragments below set the scan position for an index on the CODE field to the leftmost item and walk through successive entries, processing each record.







hmtoggle_plus1QMBasic Class Module