SEEK( ) Function
Searches an indexed table for the first occurrence of a record whose index key matches a specified expression. Issuing SEEK( ) is equivalent to issuing SEEK and FOUND( ) in succession.
Note
Visual FoxPro does not support seek operations for binary indexes.
SEEK(eExpression [, nWorkArea | cTableAlias
[, nIndexNumber | cIDXIndexFileName | cTagName]])
Parameters
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 Command.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.
Return Value
Logical. SEEK( ) returns True (.T.) if a match is found and the record pointer moves to the matching record. Otherwise, SEEK( ) returns False (.F.) if a match is not found, and the record pointer moves to the end of the file if SET NEAR is OFF or to the closest matching record if SET NEAR is ON.
Remarks
You can use SEEK( ) on a table with an index order set, or if an index order is not set on the table, set the controlling index with the 3rd parameter, nIndexNumber, cIDXIndexFileName, or cTagName. The match must be exact unless SET EXACT is set to OFF.
If you omit the nIndexNumber, IDXIndexFileName, and cTagName arguments, SEEK( ) uses the master controlling index or index tag to search for the index key.
The SET KEY setting is ignored if SEEK( ) uses a non-active index.
Example
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE customer ORDER cust_id && Opens Customer table
? SEEK('CHOPS') && Returns .T., record found