omron — LOCAL program instruction

LOCAL program instruction Details This instruction is used to declare variables to be defined only within the current program. That is, a local variable can be referenced only within its own program. Also, the names of local variables can be selected without regard for the names of local variables defined in other programs. Local variables are allocated only once during program execution, and their values are preserved between successive subroutine calls. These values are also shared if the same program is executed by multiple program tasks.

If a program that uses LOCAL (or global) variables is called by several different program tasks, or called recursively by a single task, the values of those variables can be modified by the different program instances and cause very strange program errors. Therefore, automatic variables should be used for all temporary local variables to minimize the chance of errors. (See the AUTO instruction.) Variables can be defined as automatic, global, or local. Once a variable has been assigned to a class, an attempt to assign the variable to a different class will result in the error *Attempt to redefine variable class*.

Variables can be defined only once within the same context (automatic, local, or global). Attempting to define a variable more than once (that is, with a different type) will yield the error *Attempt to redefine variable type*. For details, see Data Types and Operators in the eV+ Language User's Guide . Local variables can be referenced with monitor commands such as BPT, DELETE_, DO, HERE, LIST_, POINT, TEACH, TOOL, and WATCH by using the optional context specifier @. The general syntax is: command @task:program command_arguments For more information on specifying program context, see the section Programming eV+ in the eV+ Language User's Guide .

Example Declare the variables loc.a , $ans , and i to be local to the current program: LOCAL loc.a, $ans, i Related Keywords AUTO program instruction GLOBAL program instruction eV+Language Reference Guide, v2.x, 18319-000 Rev A Page 331