Function OrdFor() Foundation

Returns the FOR condition of an index.

Syntax
OrdFor( [<cTagName>|<nIndex>] ) --> cForExpression
Parameters
<cTagName>
<cTagName> is a character string specifying the name of an index whose FOR condition is to be returned. <cTagName> is comparable to the alias name of a work area.
<nIndex>
<nIndex> is a positive integer specifying the ordinal position in a work area of the index whose FOR condition is returned. The indexes are numbered in the order that they were opened with OrdListAdd() or SET INDEX TO.
Return

The return value of OrdFor() is a character string containing the FOR condition used to create the index. If no FOR condition was specified when the index was created or no index file is open, the function returns a null string ("").

Description

The index function OrdFor() is similar to OrdKey(), but returns the FOR condition used in creating the index instead of the index expression. If the function is called without the alias operator, it returns the FOR condition for an index in the current work area.

The ability to manage several indexes in a single index file depends on whether the active database engine (DBE) supports multiple indexes. If the current DBE does not support multiple indices, a recoverable runtime error occurs.

Examples
OrdFor()
// In the example, two indexes are created for a customer file. 
// The indexes are divided alphabetically from A-K and L-Z. 

PROCEDURE Main 
   USE Customer NEW EXCLUSIVE 

   INDEX ON Upper(LASTNAME+FIRSTNAME) ; 
        TAG A_to_K ; 
        FOR Asc( Upper(LASTNAME) ) < Asc("L") ; 
         TO CustA 

   INDEX ON Upper(LASTNAME+FIRSTNAME) ; 
        TAG L_to_Z ; 
        FOR Asc( Upper(LASTNAME) ) > Asc("K") ; 
         TO CustB 

   SET INDEX TO CustA, CustB 

   ? OrdFor()          // result: Asc( Upper(LASTNAME) ) < Asc("L") 

   ? OrdFor("L_to_Z")  // result: Asc( Upper(LASTNAME) ) > Asc("K") 
   ? OrdFor(1)         // result: Asc( Upper(LASTNAME) ) < Asc("L") 

   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.