Seek, Seek(), IndexSeek(), Find
Seek, and ye shall find.
The Bible
These commands and functions all search for data in an indexed table. SEEK and SEEK() provide the fastest way to find a single record, if an index exists for the desired data. INDEXSEEK() lets you find out whether a particular record exists, without moving the record pointer. FIND is an ancient relic, but still handy in the Command Window, if you can remember to use it.
Usage |
FIND cExpression SEEK uExpression [ ORDER nIndexNumber | IDXFile | [ TAG ] TagName [ OF CDXFile ] [ ASCENDING | DESCENDING ] ] [ IN cAlias | nWorkArea ] lFound = SEEK( uExpression [, cAlias | nWorkArea [, nIndexNumber | cIDXFile | cTagName ] ] ) lFound = INDEXSEEK( uExpression [, lMovePointer [, cAlias | nWorkarea [, nIndexNumber | cIDXFile | cTagName ] ] ] ) |
Parameter |
Value |
Meaning |
cExpression, uExpression |
The value to search for. |
|
nIndexNumber |
Numeric |
The position of the index to use among the open indexes. |
IDXFile or cIDXFile |
Filename or Character |
The stand-alone IDX file in which to search. |
TagName or cTagName |
Name or Character |
The index tag in which to search. |
CDXFile or cCDXFile |
Filename or Character |
The CDX index file containing the specified tag. |
cAlias |
Character |
The alias of the table in which to search. |
Omitted |
If nWorkArea is also omitted, search in the current work area. |
|
nWorkArea |
Numeric |
The work area in which to search. |
Omitted |
If cAlias is also omitted, search in the current work area. |
|
lMovePointer |
.T. |
Move the record pointer to either the matching record or to EOF, if there is no matching record. |
.F. |
Don't move the record pointer, whether or not a match is found. |
|
lFound |
.T. |
uExpression was found. |
.F. |
uExpression was not found. |
Example |
* This is handy in the command window USE Customer ORDER Company_Na FIND AROUND THE HORN USE Customer && No order set * Company_Na is a tag on UPPER(Company_Name) SEEK "AROUND THE HORN" ORDER Company_Na ? FOUND() && Returns .T. SELECT 0 && change work areas * Use nIndexNumber ? SEEK("ERNST HANDEL", "Customer", 1) && Returns .T. * Use cTagName ? SEEK("ERNST HANDEL", "Customer", "Company_Na") && Returns .T. SELECT Customer SEEK "H" ORDER Company_Na DESCENDING && Last "H" name * Positions pointer on record for Hungry Owl All-Night Grocers SET ORDER TO Company_Na GO TOP ? INDEXSEEK("ERNST HANDEL") && Returns .T. ? RECNO() && Returns 1, because pointer didn't move |
See Also |