Function DbSeek() Foundation
Positions the record pointer to a record based on the value of an index expression
DbSeek( <IndexKeyValue>, ; [<lSoftSeek>] , ; [<nIndex>|<cTagName>],; [<lLast>] ) --> lFound
The return value of DbSeek() is .T. (true) when the specified value was found in the active index file. Otherwise it is .F. (false).
The database function DbSeek() is the most important function for quickly searching for data. It searches for a logical record in an index file containing a logical sorting for a database file. DbSeek() searches for the value in the active index file (the controlling index) unless an index is explicitly specified with the parameter <nIndex> or <cTagName>. The value <IndexKeyValue> being searched for must have the same data type as the value of the active index expression. When <IndexKeyValue> is found in the index file, the record pointer of the database file is positioned on the corresponding record. In this case, DbSeek() returns the value .T. (true), and the return value of the function Found() is also .T.
If <IndexKeyValue> is a character string, the first entry beginning with this string is searched in the index file. The expression DbSeek( "An" ), for example, positions the record pointer on the first record whose index key starts with the letters "An".
If the value of <IndexKeyValue> is not found in the index file, the position of the record pointer depends on <lSoftSeek> or on the SET SOFTSEEK setting. Normally, SET SOFTSEEK is turned OFF (<lSoftSeek>==.F.)), causing the record pointer to be positioned on the "phantom" record if <IndexKeyValue> is not found in the index file (for DBF files this corresponds to the position LastRec()+1). The function Found() then returns the value .F. and the function Eof() returns the value .T. If SET SOFTSEEK is turned ON (<lSoftSeek>==.T.)) an "inexact" search is performed. This results in the record pointer being positioned on the first record whose value is greater than <IndexKeyValue>. If such a record exists, the function Found() and the function Eof() both return the value .F. (false).
DbSeek() searches for a value only in an index file. If no index file is open in a work area, no search is performed and the record pointer is not moved. If the function is used without the alias operator, the search is performed in the current work area.
The command SEEK can be used instead of DbSeek(). SEEK is effective only in the current work area.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.