Click or drag to resize

FieldBlockSym Function

Return a set-get code block for a field that is identified by a symbol.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.6
 FUNCTION FieldBlockSym(
	symFieldName AS SYMBOL
) AS Codeblock
Request Example View Source


Type: Symbol
A symbol that is the name of the field to which the set-get block will refer.  When executed with an argument, the code block created by this function assigns the value of the argument to <symFieldName>.
If omitted, the code block retrieves the value of <symFieldName>.

Return Value

Type: Codeblock
A runtime code block (implemented as an object) that, when evaluated, sets (assigns) or gets (retrieves) the value of the given field.
If <symFieldName> does not exist in the current work area, FieldBlockSym() returns NULL_OBJECT.
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
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.
Tip Tip
Work area:
The code block returned by FieldBlockSym() sets or gets the value of the specified field in whatever work area is current when the block is run.
For example, given work areas 1 and 2, both containing field FName:
2_FIELD->FName := "Kate"
4_FIELD->FName := "Cindy"
5cbFName := FieldBlockSym(#FNAME)
7? EVAL(cbFName)                        // "Kate"
9? EVAL(cbFName)                        // "Cindy"
Use FieldWBlock() to provide a set-get block for a field in a specific work area.
This example compares FieldBlockSym() to a code block created using the macro operator.  Note that using FieldBlockSym() avoids the speed and size overhead of the macro operator:
1// Set-Get block defined using macro operator
2cbSetGet := &("{|SetVal| If(SetVal == NIL, FName, FName := SetVal)}")
3// Set-Get block defined using FieldBlockSym()
5cbSetGet := FieldBlockSym(#FNAME)
See Also