omron — .PROGRAM program instruction

.PROGRAM program instruction See the description of the CALL instruction for an explanation of how the program arguments receive their values from a calling program and return their values to the calling program. The following rules apply to any program argument that is omitted when the program executes: l Real-valued scalar parameters can be assigned a value within a program if they are omitted. l Location, string, and belt (scalar or array) parameters, and real-valued array parameters, cannot be assigned a value within a program if they are omitted.

(AUTO variables can be used to work around this restriction, as shown in the example below.) However, undefined parameters can be passed as program arguments and then be assigned a value. NOTE: If a program attempts to assign a value to one of these omitted variables, the error *Undefined value* results. In that case, the error refers to the variable on the left side of the assignment instruction. l If an undefined or omitted parameter is passed to another program through a subsequent CALL instruction, and the type of the variable is ambiguous (i.e., the type could be real-valued or location), the parameter is assumed to be real-valued.

l Elements of an omitted array parameter cannot be passed by reference in a subsequent CALL instruction. The DEFINED real-valued function can be used within a program to check whether a program parameter is defined (meaning both: passed as a argument, and as an argument that has been assigned a value previously). The example below shows how a program can be written to accommodate undefined or omitted parameters. A comment can be included on the .PROGRAM line, which is displayed when the program is loaded from the disk and by the DIRECTORY command. Examples Define a program that expects no arguments to be passed to it:

.PROGRAM get() Define a program that expects a string-valued argument and either a location or real-valued argument (the type of the second argument is determined by its use in the program): .PROGRAM test($n, dx) The following program segment shows how a program can be written to deal with undefined or omitted parameters. The example shows part of the program example, which has a real- valued parameter and a string parameter. .PROGRAM example(real, $string) AUTO $internal.var ; Check for undefined or omitted real-valued scalar parameter. IF NOT DEFINED(real) THEN ;If parameter is undefined eV+Language Reference Guide, v2.x, 18319-000 Rev A Page 412