Understanding global blocks

Global symbols can be defined with the GLOBALS instruction

The GLOBALS instruction can be used to declare variables, constants and types for the whole program.

Important:

Defining global variables in a GLOBALS block is deprecated. Instead of GLOBALS, use PUBLIC symbols in modules to be imported with IMPORT FGL. GLOBALS is only supported for backward compatibility, to compile legacy source code.

Why not globals? Global variables visible and modifiable across the entire program code is an old concept that reduces modularity and flexibility. GLOBALS implements specific semantics that restrain source code organization; for example, it is allowed to specify a file path such as GLOBALS "../../common/myglobals.4gl". The globals file can define functions after the GLOBALS block that are ignored when including such file.

Conversely, the IMPORT FGL instruction brings more flexibility and allows a better organization of your source code, by grouping public variables in modules where other symbols (functions, types, contants) belong to the same domain.