Function DbSetOrder() Foundation

Sets the controlling index in a work area.

DbSetOrder( <nIndex> ) --> NIL
<nIndex> is a positive integer specifying the ordinal position of the index file to select as the controlling index in a work area. The index files are numbered in the order they were opened with DbSetIndex() or SET INDEX TO.

The return value of DbSetOrder() is always NIL.


The function DbSetOrder() exists for compatibility reasons. The function OrdSetFocus() should be used instead of DbSetOrder().

The index function DbSetOrder() sets the controlling index in a work area. This index determines the logical order of the records in the database file. When the function is used without the alias operator, it defines the controlling index in the current work area.

The value for <nIndex> can be from zero to the number of index files open in the work area. If the value is equal to zero, the data records are accessed in their natural order (with no logical sorting), but the open index files are still updated. A value greater than zero activates an index based on the order that the index files in the work area were opened.

The command SET ORDER can be used instead of DbSetOrder(). SET ORDER is effective only in the current work area.

// In the example, two index files for a customer file are 
// created and opened. The effect of the function DbSetOrder() 
// is then shown. 


   INDEX ON CustNo                    TO CustA 
   INDEX ON Upper(LastName+FirstName) TO CustB 

   SET INDEX TO CustA, CustB 

   DbGoTop()                 // ** CustA is controlling 
                             // ** index 

   ? IndexKey(IndexOrd())    // result: CustNo 
   ? LastName                // result: King 
   ? CustNo                  // result:  1 

   DbSetOrder(2)             // ** CustB becomes controlling 
   DbGoTop()                 // ** index 

   ? IndexKey(IndexOrd())    // result: Upper(LastName+FirstName) 
   ? LastName                // result: Anderson 
   ? CustNo                  // result: 13 

   CLOSE Customer 



If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.