Click or drag to resize

FieldWBlockSym Function

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

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.10
Syntax
 FUNCTION FieldWBlockSym(
	symFieldname AS SYMBOL,
	dwWorkArea AS DWORD
) AS Codeblock
View Source

Parameters

symFieldname
Type: Symbol
dwWorkArea
Type: UInt32
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 <symFieldName> in the work area designated by <dwWorkArea>.  If <symFieldName> does not exist in the specified work area, FieldWBlockSym() returns NULL_OBJECT.
Remarks
FieldWBlockSym() 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 <symFieldName>.  If no argument was passed, the code block retrieves the value of <symFieldName>.  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 FieldWBlockSym() to a code block created using the macro operator.  Note that using FieldWBlockSym() 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 FieldWBlockSym()
// cbSetGet created here is the functional
// equivalent of cbSetGet above
cbSetGet := FieldWBlockSym(#FName, 1)
See Also