See Also: Global Variables Used by Data Dictionaries, Constrained_Find, Constraint_Validate, Find, Open, Vfind
To indicate the success or failure of the last find.
Boolean
Whenever a Find command is executed, the Found predefined indicator is set. If the find is successful, Found is set True. If the find is unsuccessful, Found is set False. This allows you to program the appropriate action when a find command finds a record.
Clear Parts
Move 25 to Parts.Code
Find eq Parts.Code
If (Found) Send DoUpdate
If a record in the Parts table is found with the value of Parts.Code code equalling the value in the buffer (25 in this sample), Found is True and the DoUpdate method is called.
Never rely on the value of the Found indicator other than on the line immediately following the line of code that sets it. Many different commands and messages alter the value of Found and other global indicators.
Clear Parts
Repeat
Find gt Parts.Code
If (Found) Begin
// do something else
End
Until Not (Found)
The sample code above attempts to loop through all records in the Parts table. The problem is that code executed inside the if (Found) begin...end block of code may change the value of Found. If the value of Found is changed to False by the use of another command or message, this could result in the loop ending before all records have been processed by the loop.
The sample code below solves this problem by resetting the value of Found to True at the end of the if (Found) begin...end block of code, ensuring that the loop will continue after any find gt that successfully finds a record.
Clear Parts
Repeat
Find gt Parts.Code
If (Found) Begin
// do something else
Move True to Found // reset Found for repeat...until loop
End
Until Not (Found)
The FindErr Predefined Indicator is set at the same times as Found, and to the inverse of Found (True when Found is False, False when Found is True).
Found is also set by the String commands Replace and Pos to indicate whether the substring being searched for was found.
Found is set by the open command to indicate whether the file on which open was attempted was in fact opened.
The Constrained_Find command also sets Found, but unlike Find, it will bring a new record into the buffer even with Found False.
The value of Found is set by the most recent Find, (but also replace, pos, open, Constrained_Find, Constraint_Validate, etc.) regardless of where it was performed.