Returns the index filter expression of an open single-entry index (.idx) file or an index tag.
Syntax
FOR([nIndexNumber [, nWorkArea | cTableAlias]])
Returns
Character
Arguments
If you don't include any of the optional arguments, FOR( ) returns the index filter expression for the master index file or index tag. If a master index file or index tag isn't in effect (for example, you've issued SET ORDER TO to place the table in physical record order), FOR( ) returns the empty string.
nIndexNumber
Specifies the index file or tag for which the filter expression is returned. FOR( ) returns filter expressions in the following order as nIndexNumber increases from 1 to the total number of open single-entry files and structural compound and independent compound index tags:
The empty string is returned if an index or index tag is created without a FOR clause or if nIndexNumber is greater than the total number of open single-entry files and structural compound and independent compound index tags.
nWorkArea
Specifies the work area of the table for which FOR( ) returns the index filter expressions.
FOR( ) returns the empty string if a table isn't open in the work area you specify.
cTableAlias
Specifies the alias of the table for which FOR( ) returns the index filter expressions.
Visual FoxPro generates an error message if you specify a table alias that doesn't exist.
Remarks
You can create filtered indexes in Visual FoxPro. If you include the optional FOR lExpression clause in INDEX, the index file acts as a filter on the table. Only records that match the filter expression lExpression are available for display and access. Index keys are created in the index file for just those records matching the filter expression.
USE and SET INDEX both support an index file name list that lets you open multiple index files for a table. Any combination of single-entry index file names, structural compound, or independent compound index file names can be included in the index file name list. FOR( ) is identical to SYS(2021) and is provided for compatibility with dBASE IV.