Click or drag to resize

Found Function

X#
Determine if the previous search operation succeeded.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax
 FUNCTION Found() AS LOGIC
Request Example View Source

Return Value

Type: Logic
TRUE if the last search was successful; otherwise, FALSE. Found() will also return FALSE if there is no database open in the work area.
Remarks
Found() determines whether a search operation, such as DBSeek(), DBLocate(), DBContinue(), or DBSetRelation(), succeeded. When any of these commands are executed, Found() is set to TRUE if there is a match; otherwise, it is set to FALSE. If the search command is LOCATE or CONTINUE, a match is the next record meeting the scope and condition.
If the search command is FIND, SEEK or SET RELATION, a match is the first key in the controlling order that equals the search argument.
If the key value equals the search argument, Found() is TRUE; otherwise, it is FALSE. The value of Found() is retained until another record movement command is executed.
Unless the command is another search command, Found() is automatically set to FALSE. You can also use DBSetFound() to manually set this flag. Each work area has a Found() value.
This means that if one work area has a relation set to a child work area, querying Found() in the child returns TRUE if there is a match.
By default, this function operates on the currently selected work area.
It can be made to operate on an unselected work area by specifying it within an aliased expression or by calling the overload that accepts a workarea parameter (a workarea number or alias ).
Examples
This example illustrates the behavior of Found() after a record movement command:
X#
1USE sales INDEX sales
2SEEK "1000"
3QOut(Found())            // Result: FALSE
4SEEK "100"
5QOut(Found())            // Result: TRUE
6SKIP
7QOut(Found())            // Result: FALSE
This example tests a Found() value in an unselected work area using an aliased expression:
X#
1USE sales INDEX sales NEW
2USE customer INDEX customer NEW
3SET RELATION TO CustNum INTO sales
4SEEK "Smith"
5QOut(Found(), Sales->Found())
This code fragment processes all CUSTOMER records with the key value "Smith" using Found() to determine when the key value changes:
X#
1USE customer INDEX customer NEW
2SEEK "Smith"
3DO WHILE Found()
4    .
5    . <paramref name="Statements" />
6    .
7    SKIP
8    LOCATE REST WHILE Name == "Smith"
9ENDDO
See Also