Function FieldGet() Foundation

Determines the value of a field in the current record of a work area.

Syntax
FieldGet( <nFieldPos> ) --> xValue
Parameters
<nFieldPos>
<nFieldPos> is a positive integer specifying the ordinal position of a field in the record. The value for <nFieldPos> must be between 1 and FCount().
Return

The return value of FieldGet() is the current value of the field at the position <nFieldPos> in the work area. When <nFieldPos> is not a valid field position in the work area, NIL is returned.

Description

The database function FieldGet() reads the values of individual fields into memory. If the function is used without the alias operator, the value from the current work area is returned. FieldGet() allows access to records without requiring knowledge of the data structure (or the field name) since the field is specified only as a numeric field position. General input/output routines which are independent of a data structure can be programmed using this function.

Examples
Various approaches to read access to fields
// The example demonstrates various ways the value 
// of a field can be assigned to a memory variable. 

PROCEDURE Main 
   LOCAL cAlias, cField, cLastName 
   USE Customer NEW 

   cLastName := Customer->LASTNAME  // specify work area and 
                                    // field name (hard-coded) 

   cField    := "CUSTOMER->LASTNAME" // field name as character 
   cLastName := &cField             // string which is macro 
                                    // compiled 

   ? FieldPos("LASTNAME")           // result: 2 

   cLastName   := FieldGet(2)      // specify field position 

                                   // specify work area using 
                                   // alias name and alias operator: 
                                   // also pass memory variable 
                                   // containing field name as a 
                                   // character string. 
   cLastName   := Customer-> ( FieldGet( FieldPos(cField) ) ) 

   cAlias  := "CUSTOMER"           // specify work area using a 
                                   // memory variable containing 
                                   // alias name as a character 
                                   // string: also pass memory 
                                   // variable containing field 
                                   // name as a character string. 
   cName   := (Select(cAlias)) -> ( FieldGet( FieldPos(cField) ) ) 

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.