Variables allow an application to temporarily store values used by the application. Dexterity has two types of variables: local variables and global variables.
Local variables are specific to a single script and are active only while the script is running. They’re used to store intermediate values, such as the resulting value of an expression, while a script is running. To create local variables, define them at the beginning of the script they’ll be used in. The word local, followed by the type of variable (integer, long, currency, vcurrency, string, time, boolean) and the variable name are required for each local variable.
Note that you use the word long to indicate a long integer type in scripts. Use the word vcurrency to indicate a variable currency type in scripts. |
In the following example, a local integer variable named “number_of_dozen” is used to store a temporary integer value for the script. The variable is set to the value of the Quantity field divided by 12 to give the amount in dozen.
local integer number_of_dozen; number_of_dozen = 'Quantity' / 12;
When you declare a local variable, you can specify its initial value. This is shown in the following example.
local string first_name = "Steve";
Global variables are active the entire time a Dexterity application is open, so they’re available to any script in the application dictionary, at any time. Global variables are used to store information that affects the entire application, such as whether printing is currently allowed. Global variables are created in the Resource Explorer. To reference global variables in a script, the qualifier of globals must appear after the name of the global variable.
In the following example, the global variable Printing_Status is checked to determine whether items may be printed.
if Printing_Status of globals = "Yes" then run report Customer_List; else warning "Printing is currently disabled. Try again later."; end if;