Click or drag to resize

Functions.VoDbSetLocate Method

Specify the code block for a locate condition.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.16
 FUNCTION VoDbSetLocate(
	cbForCondition AS USUAL
Request Example View Source


Type: Usual
A code block that defines a condition that each record within the scope must meet in order to be processed.
If no scope is specified, cbForCondition changes the default scope to all records.
The code block should contain a logical expression.
It corresponds to the first argument of DBLocate() or VODBLocate().
It is valid until it is overwritten by the next VODBSetLocate().

Return Value

Type: Logic
TRUE if successful; otherwise, FALSE.
VODBSetLocate() allows you to change the locate condition. Once you issue a LOCATE command, DBLocate(), or VODBLocate(), you could continue searching but with a different condition. 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
Note that this function does not call the error handler and will not, therefore, produce a runtime error message or create an error object if it fails. Thus, it may be important to check the return value to determine if the function succeeded.
The global structure, StrucErrInfo, will contain needed information regarding any error that occurs.
The following example shows how to search on two different and independent criteria:
 2    LOCAL cbForCondition, cbWhileCondition, nNext, ;
 3            uRecId, lRest
 4    USE test
 5    cbForCondition := {||Proper(ALLTRIM(Name)) == ;
 6            "Charly"}
 7    cbWhileCondition := {||TRUE}    // Process to EOF
 8    nNext := -1            // Scope ALL
 9    uRecId := NIL            // Leave it at NIL
10    lRest := FALSE        // Search from top of file
11    // Search for Charly
12    DBLocate(cbForCondition, cbWhileCondition, ;
13        nNext, uRecId, lRest)
14    ? Found(), RECNO(), Name
15    // Specify a second name; Search for Odile
16    VODBSetLocate({||Proper(ALLTRIM(Name))=="Odile"})
18    ? Found(), RECNO(), Name
19    DBCloseArea()
20    RETURN Found()
See Also