omron — AUTO program instruction

AUTO program instruction Details This instruction is used to declare variables to be defined only within the current program. That is, an AUTOmatic variable can be referenced only by the specific calling instance of a program. Also, the names of AUTOmatic variables can be selected without regard for the names of variables defined in any other programs. AUTOmatic variables are allocated each time the program is called, and their values are not preserved between successive subroutine calls. These values can be displayed via monitor commands only when the program task is inactive but is on an execution stack.

When a program is first entered, automatic variables have arbitrary, undetermined values (and they are not necessarily undefined). AUTOmatic variables are lost when the program exits. Unlike a LOCAL variable, a separate copy of an AUTOmatic variable is created each time a program is called, even if it is called simultaneously by several different program tasks, or called recursively by a single task. If a program that uses LOCAL or global variables is called by several different program tasks, or recursively by a single task, the values of those variables can be modified by the different program instances and can cause very strange program errors.

Therefore, AUTOmatic variables should be used for all temporary local variables to minimize the chance of such errors. Variables can be defined as GLOBAL, AUTOmatic, or LOCAL. An attempt to define AUTOmatic, GLOBAL, or LOCAL variables with the same name will result in the error message *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 message *Attempt to redefine variable type* AUTOmatic array variables must have the size of each dimension specified in the AUTO statement.

Each index specified must represent the last element to be referenced in that dimension. The first element allocated always has index value zero. For example, the statement AUTO LOC points[3,5] allocates a transformation array with 24 elements. The left-hand index ranges from 0 to 3, and the right-hand index ranges from 0 to 5. The storage space for AUTOmatic variables is allocated on the program execution stack. If the stack is too small for the number of AUTOmatic variables declared, the task execution will stop with the error message *Too many subroutine calls* If this happens, use the STATUS monitor command to determine how much additional stack space is required.

Then, use the STACK monitor command to increase the stack size and then issue the RETRY monitor command to continue program execution. eV+Language Reference Guide, v2.x, 18319-000 Rev A Page 74