Click or drag to resize

DbEval Function

X#
Evaluate a code block for each record that matches a specified scope and/or condition.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION DbEval(
	cbExecute,
	cbForCondition,
	cbWhileCondition,
	nNext,
	nRecord,
	lRest,
	lNoOpt
) AS LOGIC CLIPPER
Request Example View Source

Parameters

cbExecute (Optional)
Type: Usual
The code block to execute for each record that matches the scope and conditions.
cbForCondition (Optional)
Type: Usual
A code block that defines a condition that each record within the scope must meet in order to be processed.
cbWhileCondition (Optional)
Type: Usual
A code block that defines another condition that each record must meet in order to be processed. As soon as a record is encountered that causes the condition to fail, the operation terminates.
If no scope is specified, cbWhileCondition changes the default scope to lRest.
You define the scope using one of these three, mutually exclusive arguments.
The default is all records.
nNext (Optional)
Type: Usual
The number of records to process, starting at nRecord. Specify 0 to ignore this argument.
nRecord (Optional)
Type: Usual
A single record number to process. Specify 0 to ignore this argument.
lRest (Optional)
Type: Usual
TRUE processes only records from nStart to the end of the file. FALSE processes all records.
lNoOpt (Optional)
Type: Usual
Disable (Rushmore) optimizations (not supported yet).

Return Value

Type: Logic
TRUE if successful; otherwise, FALSE.
Remarks
Tip Tip
The nNext, nRecord, and lRest arguments are mutually exclusive. You should not pass all three of them. And if you pass the cbWhile argument then this also controls the scope behavior.
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
On each iteration, DBEval() evaluates the specified code block. All records within the scope or matching the condition are processed until end-of-file is reached. DBEval() is similar to AEval(), which executes code for each element in an array. Like AEval(), DBEval() can be used as a primitive for the construction of commands that process database files. In fact, many of the X# database processing commands are created using DBEval().
Examples
This example uses DBEval() to enhance the DBList() function:
X#
 1GLOBAL siFCount
 2FUNCTION MyListAll(cFile AS STRING) AS LOGIC PASCAL
 3    LOCAL lRetCode AS LOGIC
 4    USE test
 5    IF Used()
 6        siFCount := FCount()
 7        cbDisp  := {|| ShowFields()}
 8        GO TOP
 9        lRetCode := DBEval(cbDisp)
10    ENDIF
11    RETURN lRetCode
12FUNCTION ShowFields() AS VOID PASCAL
13    LOCAL i AS WORD
14    IF Deleted()
15        QOut("*")
16    ELSE
17        QOut()
18    ENDIF
19    FOR i := 1 UPTO siFCount
20        QQOut(FieldGet(i))
21        QQOut(" ")
22    NEXT
See Also