DBSEEK()
Searches for a value based on an active index.
- Syntax
- DBSEEK(<expKey>, [<lSoftSeek>],[<lFindLast>]) --> lFound
- Arguments
- <expKey> Any expression
- <lSoftSeek> Toggle SOFTSEEK condition
- <lFindLast> is an optional logical value that set the current record position to the last record if successful
- Returns
- DBSEEK() returns logical true (.T.) if found, otherwise false
- Description
- This function searches for the first record in a database file whose index key matches . If the item is found, the function will return a logical true (.T.), the value of FOUND() wilI be a logical true (.T.), and the value of EOF() wilI be a logical false (.F.). If no item is found. then the function will return a logical false, the value of FOUND( ) will be a logical false (.F.), and the value of EOF( ) will be a logical true (.T.).
- This function always "rewinds" the database pointer and starts the search from the top of the file.
- If the SOFTSEEK flag is on or if is set to a logical true (.T.) the value of FOUND() wilI be a logical false and EOF() will he a logical false if there is an item in the index key with a greater value than the key expression ; at this point the record pointer will position itself on that record. However, if there is no greater key in the index,EOF() will return a logical true (.T.) value. If is not passed, the function will look to the internal status of SOFTSEEK before performing the operation. The default of is a logical false (.F.)
- Examples
- FUNCTION Main()
- USE Tests New INDEX Tests
- DBGOTO(10)
- nId:=Tests->nId
- IF Tests->(DBSEEK(nId))
- IF RLOCK()
- ? Tests->Name
- DBRUNLOCK()
- ENDIF
- ENDIF
- USE
- RETURN NIL
- ACCEPT "Employee name: " TO cName
- IF ( Employee->(DBSEEK(cName)) )
- Employee->(ViewRecord())
- ELSE
- ? "Not found"
- END
- Status
Started
- Compliance
- DBSEEK() is Compatible with CA-Clipper 5.3
- Files
- Library is rdd
- See Also