During a program processing, there is determined information that need to be stored in the computer memory to be used as the operations are run. This information is stored through identifier names called variables as they can have their content edited during the processing flow.
Therefore, a variable is any reference or value temporarily stored in the computer memory through a name and whose content varies during the processing.
The variable name has letters, numbers, or a underscore symbol. It can have up to 10 characters: the first must be a letter. To make the program user friendly, one of the programming good practices conventions is: start the variable name with a letter that represents the data type it contains. This convention is explained and deepen in the Programming Good Practices item, in this documentation.
During an application run, you can attribute the same name to different variables, as long as they are in different routines. But, you must avoid this practice. Otherwise, the ambiguity risk in the program is high, and it prevents the compiler to generate an efficient code. Besides, the program gets confused and probably even the programmer who created it will have difficulties in understanding it.
To avoid ambiguities and enable the compiler to generate an optimized code, references to table fields must be explicitly performed by preceding its name with the alias operator ( -> ), as example below:
// Name of the field that stores the amount of the Outbound Invoice item (Sales)
This syntax refers to a field in a table displayed in the work space and designed by the alias SD2.
Therefore, any ambiguity is avoided and a variable can have the same name of a field in the data table.
AdvPL enables the definition of different types of variables according to the nature of the data stored in it. Besides, these variables are not organized in classes that determine as the variable is stored, how long it is active and where, in a program, it can be used (it will be displayed. Each variable class has a specific command that declares its name and creates it during the program run.