Click or drag to resize

FieldWBlockSym Function

X#
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.19
Syntax
 FUNCTION FieldWBlockSym(
	symFieldname AS SYMBOL,
	dwWorkArea AS DWORD
) AS Codeblock
Request Example View Source

Parameters

symFieldname
Type: Symbol
The name of the field.
dwWorkArea
Type: DWord
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#
1// Set-Get block for work area 1 defined with macro operator
2cbSetGet := &("{|SetVal| If(SetVal == NIL, ;
3    1->FName, 1->FName := SetVal)}")
4// Set-Get block defined using FieldWBlockSym()
5// cbSetGet created here is the functional
6// equivalent of cbSetGet above
7cbSetGet := FieldWBlockSym(#FName, 1)
See Also