Command SEEK Foundation
Positions the record pointer based on the value of an index expression.
SEEK [LAST] <Expression> ;
ORDER [TAG] <cTagName>|<nIndex> ;
[IN <nWorkArea> | <cAlias> ] ;
[SOFTSEEK]
If <Expression> is a character string, the first entry beginning with this string is searched in the index file. The expression SEEK "An", for example, positions the record pointer on the first record whose index key starts with the letters "An".
When the value of <Expression> is not found in the index file, the position of the record pointer depends on the setting of SET SOFTSEEK. Normally SET SOFTSEEK is set to OFF, causing the record pointer to be positioned on the "Phantom" record when <Expression> is not found in the index file (with 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 set to ON, an "inexact" search is performed and the data record pointer is positioned on the first record whose value is greater than the value of <Expression>. When such a record exists, the function Found() as well as Eof() return the value .F. (false).
SEEK searches for a value in an index file. If no index file is open in the current work area, no search occurs and the record pointer remains unchanged.
The function DbSeek() is the functional equivalent of the command SEEK.
// The example shows the command SEEK and the different
// behavior caused when SOFTSEEK is ON or OFF.
PROCEDURE Main
USE Customer NEW EXCLUSIVE
INDEX ON Upper(LName+FName) TO CustName
SET INDEX TO CustName
? LName // result: Anderson
? FName // result: John
? LastRec() // result: 100
SET SOFTSEEK OFF
GO BOTTOM
** Search value corresponds to the index expression
** (upper case letters)
SEEK "ANDERSON JOHN"
? RecNo() // result: 13
** Search value does not correspond to the index expression
SEEK "Anderson John"
? RecNo() // result: 101
? Found() // result: .F.
? Eof() // result: .T.
SET SOFTSEEK ON // turn on "inexact" search
** Search value corresponds to the index expression
SEEK "ANDERSON JOHN"
? LName // result: Anderson
? FName // result: John
? Found() // result: .T.
? Eof() // result: .F.
** Search value does not correspond to the index expression
** The record with the next greatest value is found
SEEK "Anderson John"
? LName // result: Baker
? FName // result: Fred
? Found() // result: .F.
? Eof() // result: .F.
CLOSE Customer
RETURN
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.