Click or drag to resize

FieldWBlock Function

Return a set-get code block for a field, specified as a string, in a specified work area.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.08
Syntax
 FUNCTION FieldWBlock(
	cFieldName AS STRING,
	dwWorkArea AS USUAL
) AS Codeblock
View Source

Parameters

cFieldName
Type: String
The name of the field.
dwWorkArea
Type: Usual
The work area number where the field resides.

Return Value

Type: Codeblock
A runtime code block (implemented as an object) that, when evaluated, sets (assigns) or gets (retrieves) the value of <cFieldName> in the work area designated by <dwWorkArea>.  If <cFieldName> does not exist in the specified work area, FieldWBlock() returns NULL_OBJECT.
Remarks
FieldWBlock() builds a code block.  When evaluated with the Evaluate() function, the code block first selects the designated <dwWorkArea>.  If an argument was passed, the code block then assigns the value of the argument to <cFieldName>.  If no argument was passed, the code block retrieves the value of <cFieldName>.  The original work area is then reselected before the code block returns control. Note that the specified field variable does not have to exist when the code block is created but must exist before the code block is executed.
Examples
This example compares FieldWBlock() to a code block created using the macro operator.  Note that using FieldWBlock() avoids the speed and size overhead of the macro operator:
X#
// Set-Get block for work area 1 defined with macro operator
cbSetGet := &("{|SetVal| If(SetVal == NIL, ;
        1->FName, 1->FName := SetVal)}")
// Set-Get block defined using FieldWBlock()
// cbSetGet created here is the functional equivalent of cbSetGet above
cbSetGet := FieldWBlock("FName", 1)
See Also