GLOBALS
The GLOBALS / END GLOBALS block and the GLOBALS instruction.
Important: Defining GLOBAL symbols (variables, constants, types)
is deprecated and should be avoided. Instead of globals, use
PUBLIC
symbols in
modules to be imported with IMPORT
FGL
.Syntax 1: Global block declaration
GLOBALS
declaration-statement
[,...]
END GLOBALS
- declaration-statement is a variable, constant or type declaration.
Syntax 2: Importing definitions from a globals file
GLOBALS "filename"
- filename is the file containing the definition of globals.
filename can be a relative or an absolute path. To specify a path, the slash
(
/
) directory separator can be used for UNIX™ and Windows® platforms. - Use this syntax to include global declarations in the current module.
Usage
To extend the scope of variables, constants or user
types to the whole program, define a module containing a GLOBALS ... END
GLOBALS
block and include this global module with the GLOBALS
"filename"
statement in other modules.
Note: Initialization of global variables (
DEFINE var INT = 100
) is not supported.
The filename should contain the .4gl
suffix. However, the
compiler uses the file name as it is. Therefore it can accept other file extensions such as
GLOBALS "stock.glb"
.
The filename can be a relative or an absolute path. To specify a path, the
slash (/
) directory separator can be used for UNIX and Windows platforms.
When the filename specified by
GLOBALS
defines a relative
file path, the globals file will be searched relatively to the location of the source provided to
fglcomp.Note: For compatibility, fglcomp searches globals
files in pwd first, then the search is relative to the source file path. This can simplify build
scripts: the compiler can be called from any directory.