15. Embedded Forms Program Structure : The Display Block : The Initialize Section
 
Share this page                  
The Initialize Section
The initialize statement appears in the display block immediately after the display statement. Its primary purpose is to transfer data from program variables into simple fields on the form. It is executed once, when the display loop is started.
This statement has the following syntax:
initialize [(fieldname = data {, fieldname = data})];
begin;

     initialization code;
end;
The fieldname is the name of the simple field into which data is put. For example, the statement:
exec frs initialize
   (namefield = :namevar, salfield = :salvar);
takes values from two program variables and places them in simple fields when the form is first displayed. The data can also be a constant value. For example, the statement:
exec frs initialize
   (namefield = 'bill', salfield = 20000.00);
The field name can also be specified as a string variable, which allows the program to determine in what field to place the data:
exec frs initialize
   (:fieldvar = 'bill', salfield = 20000.00);
In all statements that use a field name, the field name must be the field's internal name, as specified in VIFRED, and does not necessarily bear any relationship to the field's title, which usually appears with the field on the form.
By associating a block of code with the initialize statement, you can specify an initialization operation before the form is displayed.