Function FieldPut() Foundation
Copies a value into a field of the current record in a work area.
FieldPut( <nFieldPos>, <Expression> ) --> xAssignedValue
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.
// The example demonstrates various ways a memory
// variable can be assigned to a field.
PROCEDURE Main
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 ) )
RETURN
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.