xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

FieldWBlock()

Creates a set/get code block for a field variable in a particular work area.

Syntax

FieldWBlock( <cFieldName>, <nWorkArea> ) --> bFieldWBlock

Arguments

<cFieldName>
A character string holding the name of the database field to be accessed by the returned code block.
<nWorkArea>
<nWorkArea> is the numeric ordinal position of a work area to bind the code block to. Work areas are numbered from 1 to 65535.

Return

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.

Description

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>.

Info

See also:FieldBlock(), FieldGet(), FieldPut(), MemvarBlock()
Category: Code block functions , Database functions
Source:rtl\fieldbl.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe