xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

FieldBlock()

Creates a set/get code block for a field variable

Syntax

FieldBlock( <cFieldName> ) --> bFieldBlock

Arguments

<cFieldName>
A character string holding the name of the database field to be accessed by the returned code block.

Return

The function returns a code block accessing the field variable <cFieldName>, 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 FieldBlock() creates a code block which accesses a field variable in the current work area. When evaluated with no parameter, the code block retrieves (gets) the value of <cFieldName>. 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 FieldBlock() is called. When the returned code block is passed to the Eval() function, however, the field variable <cFieldName> must exist in the current work area.

Note:  The FieldBlock() code block can be evaluated in any work area that has the specified field variable, as long as the work area is current. That is, the code block is not bound to any particular work area but is evaluated always in the context of the current work area.

Use function FieldWBlock() to create a set/get code block bound to a particular work area.

Info

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

Example

// The example creates a set/get block for the field variable
// LASTNAME in the CUSTOMER database. The field variable is
// first get and then set.

   PROCEDURE Main
      LOCAL bBlock := FieldBlock( "LastName" )

      USE Customer

      // get field variable
      ? Eval( bBlock )                 // result: Miller

      // set field variable
      EVal( bBlock, "MILLER" )
      ? LastName                       // result: MILLER

      USE

      // unused work area
      ? Eval( bBlock )                 // result: runtime error
   RETURN

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