omron — FOR program instruction

FOR program instruction FOR program instruction Syntax FOR loop_var = initial TO final STEP increment Function Execute a group of program instructions a certain number of times. Usage Considerations An END instruction must be included in a program to match every FOR. Parameters loop_var Real valued variable that is initialized when the FOR instruction is executed and is incremented each time the loop is executed (cannot be a specified value or expression). initial Real value that determines the value of the loop variable the first time the loop is executed. final Real value that establishes the value to be compared to the loop variable to determine when the loop should be terminated.

increment Optional real-value that establishes the value to be added to the loop variable every time the loop is executed. If omitted, the increment defaults to one, and the keyword STEP may also be omitted. Details The instructions between the FOR statement and the matching END statement are executed repeatedly, and loop_var is changed each time by the value of increment. The processing of this structure is as follows: 1. When the FOR statement is first entered, set loop_var to the initial value. 2. Determine the values of the increment and final parameters. 3. Compare the value of final to the value of loop_var :

l If increment is positive and loop_var is greater than final , skip to item 7 below. eV+Language Reference Guide, v2.x, 18319-000 Rev A Page 251