Importing modules

Genero BDL support the IMPORT FGL instruction to simplify programming.

The IMPORT FGL instruction

IMPORT FGL module-name must be used a the beginning of a module, to indicate that we want to use the functions, variables, types or constants implement in that module.

When referencing a symbol of an imported module, you can prefix the symbols with the module name:
IMPORT FGL custquery
...
   CALL custquery.cust_select(...)
Using IMPORT FGL have many advantages, such as:
  • Better source code organization.
  • No program linking is needed.
  • Improved source code readability.
  • Better error checking at compilation time.
  • Source code completion is available.

PUBLIC and PRIVATE symbols

To keep symbols invisible to other modules, use the PRIVATE keyword before the definition of the symbol:
PRIVATE DEFINE debug_level INTEGER
PRIVATE FUNCTION reload_data(...)
To share symbols with other modules importing the current module, use the PUBLIC keyword:
PUBLIC FUNCTION check_user_permissions(...)

A symbol is by default public or private, depending on its kind. A function is by default public, while a module variable is private. For best readability, always use the PUBLIC or PRIVATE keywords when defining module elements.

Sharing types and constants to simplify coding

Genero BDL supports user-defined type creation, to easily reuse data types in different modules.

A good practice is to define common types in a module as public, and reuse this type in other modules:
SCHEMA custdemo
...
PUBLIC t_cust_rec RECORD LIKE customer.*
PUBLIC TYPE t_cust_num LIKE customer.cust_num
Similarly, it is good practice to define constants in a module to be reused in others:
PUBLIC CONSTANT c_max_rows INTEGER = 1000
PUBLIC CONSTANT c_undef STRING = "<undefined>"