SEEK( ) Function

Example   See Also

Searches an indexed table for the first occurrence of a record whose index key matches a specified expression. Returns a logical value indicating if the search was successful.

Syntax

SEEK(eExpression [, nWorkArea | cTableAlias
  [, nIndexNumber | cIDXIndexFileName | cTagName]])

Returns

Logical

Arguments

eExpression

Specifies the index key expression for which you want SEEK( ) to search.

nWorkArea

Specifies the work area number of the table that is searched for the index key.

cTableAlias

Specifies the alias of the table that is searched.

If you omit nWorkArea and cTableAlias, the table in the currently selected work area is searched.

nIndexNumber

Specifies the number of the index file or tag that is used to search for the index key. nIndexNumber refers to the index files as they are listed in USE or SET INDEX. Open .idx files are numbered first in the order in which they appear in USE or SET INDEX. Tags in the structural .cdx file (if one exists) are then numbered in the order in which they were created. Finally, tags in any open independent .cdx files are numbered in the order in which they were created. For more information about index numbering, see SET ORDER.

cIDXIndexFileName

Specifies an .idx file that is used to search for the index key.

cTagName

Specifies a tag of a .cdx file that is used to search for the index key. The tag name can be from a structural .cdx file or any open independent .cdx file.

Note   The .idx file takes precedence if duplicate .idx file and tag names exist.

Remarks

You can use SEEK( ) only with a table with an index order set, and you can search only for an index key. The match must be exact unless SET EXACT is set to OFF.

If a match is found, SEEK( ) returns true (.T.), and the record pointer moves to the matching record. If no match is found, SEEK( ) returns false (.F.) and the record pointer moves to the end of the file. Issuing SEEK( ) is equivalent to issuing SEEK and FOUND( ) in succession.

If you omit the nIndexNumber, IDXIndexFileName, and cTagName arguments, SEEK( ) uses the master controlling index or index tag to search for the index key.