ui.Form.setDefaultInitializer

Define the default initializer for all forms.

Syntax

ui.Form.setDefaultInitializer(
   initializer STRING )
  1. initializer is the name of a function in the program. This can be a simple function name, or a function name prefixed by a module name in the form "module-name.function-name".

Usage

Specify a default initialization function with the ui.Form.setDefaultInitializer() method, to implement global processing when a form is opened with OPEN FORM / DISPLAY FORM or with OPEN WINDOW ... WITH FORM.
Note:

The ui.Form.setDefaultInitializer() method is deprecated, use ui.Form.setDefaultInitializerFunction() instead.

The method takes the name of the initialization function as a parameter. It can be prefixed by the module name followed by a dot.

The initialization function name is case insensitive.

The module prefix of the initialization function name is case sensitive (unlike the function name, which is case insensitive). If the module is not yet loaded, it will be loaded automatically when the initializer function is needed.

The initialization function is called 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 setup.init_form_setup(FALSE)
    CALL ui.Form.setDefaultInitializer("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:
PRIVATE DEFINE with_toolbar BOOLEAN

PUBLIC FUNCTION init_form_setup(tb)
    DEFINE tb BOOLEAN
    LET with_toolbar = tb
END FUNCTION

PUBLIC FUNCTION form_init(form ui.Form)
    IF with_toolbar THEN
       CALL form.loadToolBar("common_toolbar")
    END IF
END FUNCTION