Click or drag to resize

VoDbSetLocate Function

Specify the code block for a locate condition.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.08
Syntax
 FUNCTION VoDbSetLocate(
	cbForCondition AS USUAL
) AS LOGIC
View Source

Parameters

cbForCondition
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: Boolean
TRUE if successful; otherwise, FALSE.
Remarks
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.
Examples
The following example shows how to search on two different and independent criteria:
X#
FUNCTION Locators() AS LOGIC
        LOCAL cbForCondition, cbWhileCondition, nNext, ;
                        uRecId, lRest
        USE test
        cbForCondition := {||Proper(ALLTRIM(Name)) == ;
                        "Charly"}
        cbWhileCondition := {||TRUE}        // Process to EOF
        nNext := -1                        // Scope ALL
        uRecId := NIL                        // Leave it at NIL
        lRest := FALSE                // Search from top of file
        // Search for Charly
        DBLocate(cbForCondition, cbWhileCondition, ;
                nNext, uRecId, lRest)
        ? Found(), RECNO(), Name
        // Specify a second name; Search for Odile
        VODBSetLocate({||Proper(ALLTRIM(Name))=="Odile"})
        CONTINUE
        ? Found(), RECNO(), Name
        DBCloseArea()
        RETURN Found()
See Also