Module "labels.4gl": This module defines the text that should be
displayed on the screen
GLOBALS
CONSTANT g_lbl_val = "Index:"
CONSTANT g_lbl_idx = "Value:"
END GLOBALS
Module "globals.4gl": Declares a global array and a constant containing
its size
GLOBALS "labels.4gl" -- this statement could be line 2 of main.4gl
GLOBALS
DEFINE g_idx ARRAY[100] OF CHAR(10)
CONSTANT g_idxsize = 100
END GLOBALS
Module "database.4gl": This module could be dedicated to database
access
GLOBALS "globals.4gl"
FUNCTION get_id()
DEFINE li INTEGER
FOR li = 1 TO g_idxsize -- this could be a FOREACH statement
LET g_idx[li] = g_idxsize - li
END FOR
END FUNCTION
Module "main.4gl": Fill in the global array and display the
result
GLOBALS "globals.4gl"
MAIN
DISPLAY "Initializing constant values for this application..."
DISPLAY "Filling the data from function get_idx in module database.4gl..."
CALL get_id()
DISPLAY "Retrieving a few values from g_idx"
CALL display_data()
END MAIN
FUNCTION display_data()
DEFINE li INTEGER
LET li = 1
WHILE li <= 10 AND li <= g_idxsize
DISPLAY g_lbl_idx CLIPPED || li || " " || g_lbl_val CLIPPED || g_idx[li]
LET li = li + 1
END WHILE
END FUNCTION