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.19
Syntax FUNCTION FieldWBlock(
cFieldName AS STRING,
dwWorkArea AS USUAL
) AS Codeblock
public static Codeblock FieldWBlock(
string cFieldName,
Usual dwWorkArea
)
Request Example
View SourceParameters
- 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:
1
2cbSetGet := &("{|SetVal| If(SetVal == NIL, ;
3 1->FName, 1->FName := SetVal)}")
4
5
6cbSetGet := FieldWBlock("FName", 1)
See Also