Returns the index key expression for an index tag or index file.
Syntax
KEY([CDXFileName,] nIndexNumber [, nWorkArea | cTableAlias])
Returns
Character
Arguments
CDXFileName
Specifies the name of a compound index file. KEY( ) returns the index key expressions of the .cdx file's index tag. The compound index file you specify can be the structural compound index file automatically opened with the table, or it can be an independent compound index file.
nIndexNumber
Specifies which index key expression to return.
USE and SET INDEX both support an index file list that lets you open multiple indexes for a table. Any combination of single-entry .idx index files, structural compound index files, or independent compound index files can be included in the index file list.
The numeric expression nIndexNumber specifies which index expression to return from the open index files. KEY( ) returns index expressions from open index files in the following order as nIndexNumber increases from 1 to the total number of open single-entry .idx files and structural compound and independent compound index tags:
The empty string is returned if nIndexNumber is greater than the total number of open single-entry .idx files and structural compound and independent compound index tags.
nWorkArea
Specifies the work area number of the table whose index key expressions you want KEY( ) to return.
If a table isn't open in the work area you specify, KEY( ) returns the empty string.
cTableAlias
Specifies the alias of the table whose index key expressions you want KEY( ) to return.
If no table has the alias you specify, Microsoft Visual FoxPro generates an error message.
If you omit nWorkArea and cTableAlias, the index key expressions are returned for the table open in the current work area.
Remarks
An index key expression is specified when an index tag or index file is created with INDEX. The index key expression determines how a table is displayed and accessed when the index tag or index file is opened as the master controlling index tag or file.
For more information on creating index tags, index files, and index key expressions, see INDEX.