| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Creates a set/get code block for a field variable in a particular work area.
FieldWBlock( <cFieldName>, <nWorkArea> ) --> bFieldWBlock
The function returns a code block accessing the field variable <cFieldName> in the work area <nWorkArea>, or NIL when an illegal parameter is passed. The code block accepts one parameter used to assign a value to the field variable.
The code block function FieldWBlock() creates a code block which accesses a field variable in the work area specified with <nWorkArea>. By this, the code block is bound to the work area. When evaluated with no parameter, the code block retrieves (gets) the value of <cFieldName> in the particular work area. If one parameter is passed, the corresponding value is assigned (is set) to the field variable.
It is not necessary that a database is open when FieldWBlock() is called. When the returned code block is passed to the Eval() function, however, the field variable <cFieldName> must exist in the work area <nWorkArea>.
| See also: | FieldBlock(), FieldGet(), FieldPut(), MemvarBlock() |
| Category: | Code block functions , Database functions |
| Source: | rtl\fieldbl.prg |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example creates a set/get code block accessing work area #10.
// A database is opened in this work area, and an unused work area
// is selected as current to demonstrate that the code block is bound
// to work area #10.
PROCEDURE Main1
LOCAL bBlock := FieldWBlock( "LastName", 10 )
SELECT 10
USE Customer ALIAS Cust
SELECT 0
? Used() // result: .F.
// get field variable
? Eval( bBlock ) // result: Miller
// set field variable
EVal( bBlock, "Smith" )
? Cust->LastName // result: Smith
? Eval( bBlock ) // result: Smith
CLOSE ALL
RETURN
http://www.xHarbour.com