Function FieldPut() Foundation

Copies a value into a field of the current record in a work area.

FieldPut( <nFieldPos>, <Expression> ) --> xAssignedValue
<nFieldPos> is a positive integer specifying the ordinal position of a field in the record of a work area. The value for <nFieldPos> must be between 1 and FCount().
<Expression> is an expression whose value is assigned to the field. The data type of <Expression> must be the same as the data type of the field. The exception is memo fields (field type "M") which can be assigned either a character string (data type "C") or the contents of another memo field.

FieldPut() returns the value assigned to 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.


The database function FieldPut() assigns a value to a single field of a record in a work area. If the function is used without the alias operator, the assignment occurs to a field in the current work area. FieldPut() allows write access to records without knowing the data structure or the field name by specifying only the numeric field position. Generic input/output routines can be programmed independent of the data structure using this function.

Various possibilities for write access to fields
// The example demonstrates various ways a memory 
// variable can be assigned to a field. 

   LOCAL cAlias, cField , cLastName := "Miller" 
   USE Customer NEW 

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

   REPLACE Customer->LASTNAME WITH cLastName  // command syntax 

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

   REPLACE &cField WITH cLastName   // command syntax 

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

   FieldPut( 2, cLastName )         // specify field position 

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

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



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.