Command SET ORDER Foundation

Specifies the controlling index in the current work area or the work area specified.

SET ORDER TO [<nIndex>] | TAG <cTagName>
    [OF <cIndexfile>]
    [IN <nWorkArea> | <cAlias> ]
    [ASCENDING | descending]
thread-local, current work area
<nIndex> is a positive integer specifying the ordinal position within the current work area of the index to set as the controlling index. Indexes are numbered in the order they were opened using SET INDEX TO or DbSetIndex(). When the argument is missing, the value zero is assumed.
Instead of the numeric ordinal, the tag name of an index can be used. It corresponds with the character string specified for the TAG option of the INDEX command. It can be specified as either a literal or a character expression in parentheses.
OF <cIndexFile>
<cIndexFile> is a character string containing the file name of the index file of which a specific order shall become the controlling index. The filename can be specified without pathname and extension.
IN <nWorkArea>
<nWorkArea> is a positive integer specifying the ordinal number of the work area being selected.
IN <cAlias>
This argument is either a literal alias name or a character expression containing the alias name in parentheses. The alias name indicates the work area whose files are to be closed.
The option ASCENDING switch the navigational direction of the order to be ascending. This is the default setting.
The option DESCENDING switches the navigational behaviour of the order to be descending. See the function DbSetDescend() for more details.

SET ORDER determines the controlling index in the current work area. This index specifies the logical order of the records in the work area.

The value for <nIndex> must be between zero and the number of open index files in the work area. When the value is equal to zero, access to the records occurs in their natural order (with no logical sorting). However, the open index files continue to be updated. A value not equal to zero activates an index based on the order that the index files were opened in the work area.

// In the example, two index files are created for a 
// customer file. The effect of the command SET 
// ORDER is shown. 


   INDEX ON CustNo             TO CustA 
   INDEX ON Upper(LName+FName) TO CustB 

   SET INDEX TO CustA, CustB 

   GO TOP                    // ** CustA is controlling 
                             // ** index 

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

   SET ORDER TO 2            // ** CustB becomes controlling 
   GO TOP                    // ** index 

   ? IndexKey(IndexOrd())    // result: Upper(LName+FName) 
   ? LName                   // 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.