Language Reference Guide : 4. System Classes : FieldObject Class : SetFieldValue Method
 
Share this page                  
SetFieldValue Method
The SetFieldValue method sets the value of a field.
This method has the following syntax:
integer = FieldObject.SetFieldValue(value = variable)
This method has the following parameter:
value
Specifies the value that you want to place in the field. The data types of the field and the value you are assigning to the field must be the same or compatible. If the field allows nulls, you can assign a null.
This method provides a way to set the value of dynamically created fields because these fields do not have associated variables that you can reference in the 4GL code. Use this method with any field that you have created dynamically or in Workbench.
For example, assume that you want to set the value of a field and know only its name. You can use this method, in conjunction with the FieldByName method, to set the value with the following 4GL code:
/* declarations */
ret_value = integer;
fld = FieldObject;
...
/* Set value of an entry field named salary_fld, of
** type money
*/
fld = CurFrame.FieldByName(name = 'salary_fld');
ret_value = fld.SetFieldValue(value = 10000.0);
The FieldByName method returns the field object that represents the given field (salary_fld, in this example), and the SetFieldValue methods uses that field object to set the value of the field.
If this method is successful, it returns ER_OK. If it is not successful, it returns a non-zero value. Descriptions of system constant values and their numeric equivalents are listed in Error Codes.
For more information about using this method, see the Programming Guide.