
100
Notes: as in the above program, the initial value of the variable R[1] of the loop R[1] is 0, the final
value is 3, and the step value is 1. The value will be added by 1after each cycle. The first cycle
assigns 0 to R[1]. The second cycle R[1]=R[1]+step value=1. The third cycle R[1]=2. The fourth
cycle R[1]=3, which meets the final value, and the cycle ends, so there are four cycles in total.
Steps:
1. Select the previous line of the instruction line which needs to be inserted
2. Select the instruction→Loop instruction→FOR
3. Set the initial value and the final value in turn
4. Click to set step button, set the step value, click OK
Figure 21-6 FOR Loop instruction
5. Click the "OK" button in the operation column to add the For condition
6. Select the end position of the loop instruction line
7. Select instruction→Loop instruction→END FOR
8. Click OK in the operation column to add the FOR loop instruction.
19.5.1.2 BREAK in the FOR Loop instruction
BREAK instruction is used to interrupt the program loop, when this instruction is executed, exit and
end the current loop.
FOR R[1]=R[2] TO R[3] BY R[4]
’Program Content
BREAK
END FOR
Example
:
FOR R[1]=R[2] TO R[3] BY R[4]
J P[1] VEL=50
J P[2] VEL=50 ‘Cyclic movement between two points,
BREAK ‘When execute the break sentence, interrupt and exit the
current loop
END FOR