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.

Usage

Specify a default initialization function with the ui.Form.setDefaultInitializer() method, to implement global processing when a form is opened.

Use this method to define a global/default initialization function for all forms of the program.

The method takes the name of the initialization function as a parameter.

Important: The initialization function name is case insensitive.

The initialization function is called with the ui.Form object as the parameter.

When a form is loaded with OPEN FORM / DISPLAY FORM or with OPEN WINDOW ... WITH FORM, the initialization function is called with a ui.Form object as a parameter.

Example

The form file form1.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 "form1"
    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(f)
    DEFINE f ui.Form
    IF with_toolbar THEN
       CALL f.loadToolBar("common_toolbar")
    END IF
END FUNCTION