Function Found() Foundation

Determines whether the last search operation was successful.

Syntax
Found() --> lSuccess
Return

The return value of Found() is .T. (true) when the last search operation executed in a work area was successful. When a search operation has failed or when no file is open in the specified work area, Found() returns the value .F.(false).

Description

The database function Found() indicates whether the last search operation in a work area was successful. When the function is used without the alias operator, it returns the success of the last search operation in the current work area. Search operations are explicitly executed using the function DbSeek() and implicitly (automatically) occur when a relation is defined between two or more work areas using DbSetRelation() or the command SET RELATION TO. Other search operations are performed using DbLocate() and DbContinue().

Search operations seek a value in a work area. When the search value is found in the work area, Found() returns the value .T. (true). Otherwise it returns the value .F. (false). This value is returned by the function until the record pointer in the work area is moved. Each work area has its own Found() status. As soon as the record pointer is moved, the Found() status in the work area is set to the value .F. (false).

The functions DbLocate() and DbContinue() test a condition for each data record in a work area. The search actually occurs in the database file of the work area and Found() then returns .T. (true) when the search condition matches the current record. All other search commands and functions execute a search in the controlling index for the specified value. If the search value is found in the index, Found() returns .T. (true). Otherwise it returns .F. (false).

The return value of Found() can be explicitly set between search operations by the function DbSetFound().

Examples
Found()
// The example shows the return value of Found() after 
// search operations in various work areas. 

PROCEDURE Main 
   LOCAL cCustNo := "    13" 
   USE Customer NEW EXCLUSIVE 
   INDEX ON CustNo TO CustA 
   SET INDEX TO CustA 

   USE Invoice NEW EXCLUSIVE 
   INDEX ON CustNo TO InvA 
   SET INDEX TO InvA 

   ? Alias()                      // result: INVOICE 
   DbSeek( cCustNo ) 
   ? Found()                      // result: .T. 

   ? Customer->( Found() )        // result: .F. 

   Customer->( DbSeek( cCustNo ) ) 
   ? Customer->( Found() )        // result: .T. 

   ? Alias()                      // result: INVOICE 
   DbSkip() 
   ? Found()                      // result: .F. 

   ? Customer->( Found() )        // result: .T. 

   CLOSE DATABASES 
RETURN 
Feedback

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.