Global_Variable Command
See Also: Global Variables, DataFlex Built-in Global Variables
Purpose
Use the Global_Variable command to ensure a variable declaration is unambiguously defined as being global when so intended.
Syntax
For Strings
Global_Variable {data-type} {variable-name} [{maximum-length}]
For All Other Data Types
Global_Variable {data-type} {variable-name}
Parameters
- {data-type}: The name of the global variable that is being declared.
- {variable-name}: The name of the global variable that is being declared.
- {maximum-length}: The maximum number of characters that the global string can contain; between 1 and 4096. If
{maximum-length}is omitted, the global String variable's length will be 80 characters.
What It Does
Variables declared outside procedures and functions are implicitly global, but using the Global_Variable command reduces ambiguity and clearly declares the intent for a variable to be global. This practice minimizes the chance of code misinterpretation.
You can also use the Global_Variable command to declare global variables inside functions and procedures, but this technique is strongly discouraged, as it creates code that is difficult to follow.
Example
Global_Variable String gsCompanyName
This example defines a global String variable named gsCompanyName (with an implied maximum length of 80 characters).