ui.Form.setDefaultInitializerFunction
Define the default initializer for all forms.
Syntax
ui.Form.setDefaultInitializerFunction(
initializer FUNCTION(
form ui.Form
) RETURNS ()
)
- initializer is a function reference that implements the form initialization code.
Usage
Specify a default initialization function with the
ui.Form.setDefaultInitializerFunction()
method, to implement global processing
when a form is opened with OPEN FORM / DISPLAY FORM
or with OPEN WINDOW
... WITH FORM
.
Use this method to define a global/default initialization function for all forms of the program.
The method takes a function reference as a parameter. The initialization function must be defined
with the ui.Form
object as the
parameter.
Example
The form file form.per:
LAYOUT
GRID
{
[f1 ]
}
END
END
ATTRIBUTES
EDIT f1 = FORMONLY.cust_name;
END
The main module:
IMPORT FGL setup
MAIN
DEFINE cust_name STRING
CALL ui.Form.setDefaultInitializerFunction(FUNCTION setup.form_init)
OPEN FORM f1 FROM "form"
DISPLAY FORM f1 -- initialization function is called
INPUT BY NAME cust_name
END MAIN
The imported module
setup.4gl:
PUBLIC FUNCTION form_init(form ui.Form) RETURNS ()
CALL form.loadToolBar("common_toolbar")
END FUNCTION