Global Variables and Constants
You can use ABF or Vision to declare global components—variables and constants—to use in an application. You then can use these components in your 4GL code for any frame or procedure.
You can use a global variable or constant in the same manner as any other variable in an application. The only exceptions are that you cannot use global constants:
• On the left side of an assignment
• As the target of a select statement
Always precede a global variable or constant with a colon(:).
When naming global constants and variables:
• Do not use the same name for a global variable and a global constant in the same application.
• Local variable definitions override constant and global variable definitions with the same names.
You can use global constants wherever strings or identifiers are accepted in 4GL, including both the menu item and the explanation in menu item activations. In the following example, the constant edit_expl is given a value before the program runs. This string contains an explanation.
:edit ( explanation = :edit_expl ) =
begin
...
end
You set values for global variables and constants as follows:
• All global variables are created with an initial value of 0 or the empty string. You must write 4GL code to set a different initial value. You can change the value of a global variable at any point in an application.
You generally set the initial value of a global variable in the starting frame or procedure of an application, so that it is available to any other frame or procedure that uses the variable. For information on how to verify that you have initialized a global variable before you use it, see the section Using a Procedure to Test Global Variables in
Using the Callproc Statement.
• You set the value of a global constant when you create the constant in ABF or Vision. You cannot use 4GL to assign a value to a constant or pass it with the byref keyword.
To change the value of a global constant, you must edit the constant's definition in ABF or Vision. You can create files to store alternate sets of values for constants. For more information on using constants, see the ABF or Vision part of this guide.
Last modified date: 04/03/2024