Function OrdSetFocus() Foundation

Sets the controlling index in a work area.

Syntax
OrdSetFocus( [<cTagName>|<nIndex>] ) --> cLastIndexName
Parameters
<cTagName>
<cTagName> is a character string specifying the name within the index file of the index to set as the controlling index. <cTagName> is comparable to the alias name of a work area.
<nIndex>
<nIndex> is a positive integer specifying the ordinal position within a work area of the index to select as the controlling index. The indexes are numbered in the order that they were activated using OrdListAdd() or SET INDEX TO.
Return

The return value of OrdSetFocus() is a character string containing the name of the controlling index previously set.

Description

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

When no argument is passed to the function, it returns the index name of the controlling index. Otherwise, the specified index becomes the controlling index and the index name of the previous controlling index is returned.

The activation of an index causes the data records of the database file in the work area to appear in the logical order predetermined by the index. When the value for <nIndex> is equal to zero, access to data records is in natural order (not in logical order). In this case, any open index files still continue to be updated.

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

PROCEDURE Main 

   USE Customer NEW EXCLUSIVE 
   INDEX ON CUSTNO ; 
        TAG C_Number ; 
         TO CustA 

   INDEX ON Upper(LASTNAME+FIRSTNAME) ; 
        TAG C_LastName ; 
         TO CustB 

   SET INDEX TO CustA, CustB 

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

   ? OrdKey()                  // result: CUSTNO 
   ? LastName                  // result: King 
   ? CustNo                    // result:  1 

   ? OrdSetFocus("C_LastName") // result: C_Number 
                               // ** CustB is controlling 
   DbGoTop()                   // ** index 

   ? OrdKey()                  // result: Upper(LASTNAME+FIRSTNAME) 
   ? LastName                  // result: Anderson 
   ? CustNo                    // result: 13 

   CLOSE Customer 

RETURN 

Feedback

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.