Function FieldBlock() Foundation

Creates a set/get code block for a database field.

Syntax
FieldBlock( <cFieldName> ) --> bFieldBlock
Parameters
<cFieldName>
<cFieldName> is a character string containing the name of the field whose data the code block will read or modify.
Return

The return value of FieldBlock() is a code block which accesses the data of a field when executed.

Description

The code block function FieldBlock() creates a code block that accesses a field in the current work area when it is executed. When the code is evaluated and no value is passed to block, it retrieves the current value of the field <cFieldName> and returns it. Otherwise it writes the passed value into the field and returns this new value.

The code block of FieldBlock() works only for field names. When the field name exists in multiple work areas, the code block returns the value from the field in the work area current when the block is evaluated. To create a set/get code block inherently tied to a specific work area, the function FieldWBlock() must be used.

When FieldBlock() is called, no file needs to be open in the work area. A file containing a field with the name <cFieldName> only needs to be open in the current work area when the code block is evaluated. If the field <cFieldName> does not exist when the code block is evaluated, a runtime error occurs.

Examples
FieldBlock()
// The example illustrates the effect of the code 
// block created by FieldBlock() when it is evaluated 
// with and without an argument. 

PROCEDURE Main 
   LOCAL bBlock 

   USE Customer NEW 
   USE Address  NEW 

   bBlock := FieldBlock( "LastName" ) 

   SELECT Customer 
   ? LastName                         // result: King 
   ? Eval( bBlock )                   // result: King 
   ? Eval( bBlock, "KING" )           // result: KING 
   ? LastName                         // result: KING 

   SELECT Address 
   ? LastName                         // result: Bell 
   ? Eval( bBlock )                   // result: Bell 
   ? Eval( bBlock, "BELL" )           // result: BELL 
   ? LastName                         // result: BELL 

   CLOSE DATABASES 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.