Returns the key expression of the specified index.


KEY([<.mdx filename>,] [<index position expN> [,<alias>]])

<.mdx filename expC>

The .MDX file that contains the index tag you want to check. The .MDX must be opened in the specified work area. If omitted, all open indexes, including the production .MDX file, are searched.

<index position expN>

the numeric position of the index tag in the specified .MDX file, or the position of the index in the list of open indexes.


The work area you want to check.


Unlike most functions, the first parameter is optional. If you omit the first parameter, the remaining parameters shift forward one; the second parameter becomes the first parameter, and so on.


KEY( ) returns a string containing the key expression of the specified index. To see the value of the key expression for a given record, store the string returned by KEY( ) in a private variable. Then use macro substitution to evaluate the expression.

The index must be referenced by number. If you do not specify an .MDX file to check, index numbering in the list of open indexes is complicated if you have open .NDX indexes or you have open non-production .MDX files. For more information on index numbering, see SET INDEX. Either way, it is often easier to reference an index tag by name by using the TAGNO( ) function to get the corresponding position number.

If you do not specify an index tag, KEY( ) checks the current master index tag and returns an empty string if there is no master index.

If the specified .MDX file or index tag does not exist, KEY( ) returns an empty string.


No equivalent.