omron — FOR program instruction

FOR program instruction l If increment is negative and loop_var is less than (that is, more negative than) final , skip to item 7 below. 4. Execute the group of instructions following the FOR statement. 5. When the END step is reached, add the value of increment to the loop variable. 6. Go back to item 3 above. 7. Continue program execution at the first instruction after the END statement. loop_ var retains the value it had at the time of the test in item 3 above. Note that the group of instructions in the FOR structure may not be executed at all if the test in item 3 fails the first time.

The values of initial , increment, and final when the FOR statement is first executed determine how many times the group of instructions are executed. Any changes to the values of these parameters within the FOR loop have no effect on the processing of the FOR structure. Changes to the loop variable within the loop affect the operation of the loop and should normally not be done. NOTE: If initial, final, or increment are not integer values, rounding in the floating point computations may cause the loop to be executed more or fewer timer than expected. Example The following example sets all elements of a 10x10 array to 0:

FOR i = 1 TO 10 array[i,j] = 0 END END FOR j = 1 TO 10 Related Keywords DO program instruction EXIT program instruction NEXT program instruction WHILE program instruction eV+Language Reference Guide, v2.x, 18319-000 Rev A Page 252