Rules for globals usage

Follow the rules described in this topic in order to use globals properly.

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.

Rules for GLOBALS usage:

  1. If you modify the globals file, you must recompile all the modules that include the file.
  2. If a local element has the same name as another variable that you declare in the GLOBALS statement, only the local variable is visible within its scope of reference.
  3. You can declare several GLOBALS .. END GLOBALS blocks in the same module.
  4. A source file with GLOBALS .. END GLOBALS block must not contain any executable statement.
  5. Do not write a declaration statement outside a GLOBALS ... END GLOBALS block in the globals file.
  6. You do not need to compile the source file containing the GLOBALS block. However, it is recommended to compile the globals file to detect errors.
  7. You can declare several GLOBALS "filename" instructions in the same globals using module.
  8. Although you can include multiple GLOBALS ... END GLOBALS statements in the same application, do not declare the same identifier within more than one GLOBALS declaration. Even if several declarations of a global elements defined in multiple places are identical, declaring any global element more than once can result in compilation errors or unpredictable runtime behavior.
  9. A GLOBALS .. END GLOBALS block can hold GLOBALS "filename" instructions. In such case, the specified files will be included recursively.