User`s guide

Variable Classes
In addition to having a data type, variables belong to one of three classes, GLOBAL, LOCAL,
or AUTOMATIC. These classes determine how a variable can be altered by different calling
instances of a program.
Global Variables
This is the default class. Unless a variable has been specifically declared to be LOCAL or AUTO,
a newly created variable is considered global. Once a global variable has been initialized, it is
available to any executing program
1
until the variable is deleted or all programs that
reference it are removed from system memory (with a DELETE or ZERO instruction). Global
variables can be explicitly declared with the GLOBAL program instruction.
GLOBAL DOUBLE dbl_real_var
Global variables are very powerful and should be used carefully and consciously. If you
cannot think of a good reason to make a variable global, good programming practice dictates
that you declare it to be LOCAL or AUTO.
Local Variables
Local variables are created by a program instruction similar to:
LOCAL the_local_var
where the variable the_local_var is created as a local variable. Local variables can be changed
only by the program in which they are declared.
An important difference between local variables in V+ and local variables in most other high-
level languages is that V+ local variables are local to all copies (calling instances) of a
program, not just a particular calling instance of that program. This distinction is critical if
you write recursive programs. In recursive programs you will generally want to use the next
variable class, AUTO.
Automatic Variables
Automatic variables are created by a program instruction similar to:
AUTO the_auto_var
where the_auto_var is created as an automatic variable. Automatic variables can be
changed only by a particular calling instance of a program.
AUTO statements cannot be added or deleted when the program is on the stack. See "Special
Editing Situations."
AUTO DOUBLE dbl_auto_var
Variable Classes
(Undefined variable: Primary.Product_Name_V)Language User's Guide, version
17.x
Page 107