Four Js Development Tools Forum

General => Ask Reuben => Topic started by: Reuben B. on April 29, 2020, 05:29:30 am



Title: Ask Reuben 13 - No More Globals
Post by: Reuben B. on April 29, 2020, 05:29:30 am
Does your code make use of GLOBALS, and do you find maintaining that code can be troublesome?   To increase code re-usability and readability, use modular concepts and define PUBLIC variables in one or more modules that are imported into other modules as required with the IMPORT FGL instruction.  In short ...
 
Code
  1. GLOBALS "filename.4gl"
  2.  

... can be replaced with ...
 
Code
  1. IMPORT FGL fileName
  2.  


... and in this module, the GLOBALS keyword ...
 
Code
  1. GLOBALS
  2. DEFINE variableName dataType
  3. END GLOBALS

... can become ...
 
Code
  1. PUBLIC DEFINE variableName dataType
  2.  

You can split your monolithic globals file into one or more smaller modules as required, and only reference the appropriate modules.
 
Read more at https://4js.com/ask-reuben/ig-13/