omron — CALLS program instruction

CALLS program instruction Examples The program segment below demonstrates how the CALLS instruction can be used to branch to a subroutine whose name is determined when the program is executed. First the program reads a set of four digital input lines (1001 to 1004) to determine which of sixteen different part types it is dealing with. The part type is considered to be a hexadecimal number, which is converted to the corresponding ASCII character. Once the character is defined, the appropriate subroutine (that is, part.0, part.1, ..., part.f) is called to process the part.

(The part-type value is also used to select the portion of the two-dimensional array argument that is passed to the subroutine.) type = BITS(1001,4) ;Get part type from digital input $type = $ENCODE(/H0, type) ;Convert to ASCII character CALLS "part."+$type(arguments[type,], status) This example can be made more robust by using the STATUS real-valued function to make sure the proposed subroutine exists before it is called. Using this function avoids possible errors from undefined program names. Related Keywords CALL program instruction CALLP program instruction .PROGRAM program instruction RETURN program instruction eV+Language Reference Guide, v2.x, 18319-000 Rev A Page 115