KEYMATCH()

From Lianjapedia
Jump to: navigation, search

Purpose

Function to determine whether a specified key value already exists

Syntax

KEYMATCH(<exp> [<index number>[,<workarea>]])

See Also

DISPLAY STATUS, INDEX, LIST STATUS, REFERENCES(), SEEK, SEEK(), SET DELETED, SET ORDER

Description

The KEYMATCH() function returns TRUE (.T.) if the specified key value <exp> exists in an open index. The KEYMATCH() function will search the current ndx (single index) file, or the controlling tag of a dbx (multiple index) file, unless the number of another index file is specified. The optional <index number> clause can contain the number of an ndx file in a list of open indexes, or the number of a tag in an open .dbx file. If you are specifying a tag in a dbx file other than the currently active dbx file, you must specify the dbx file name and then the tag number.

Index numbers can be listed using the DISPLAY | LIST STATUS command. The optional <workarea> clause is used to check indexes in other workareas. When using the <workarea> clause, the <index number> clause must also be used.

KEYMATCH() ignores the SET DELETED ON|OFF set command and always takes records marked for deletion into account when determining whether the key value exists. This ensures that subsequent recalling of deleted records does not compromise the integrity of unique index keys.

Example

m_val=part_no
if keymatch(m_val)
    dialog box "This part number already exists!"
endif