Flexible NC programming
1.12 Check structures
Job planning
102 Programming Manual, 07/2010, 6FC5398-2BP40-0BA0
1.12.3 Count loop (FOR ... TO ..., ENDFOR)
Function
The count loop is used if an operation must be repeated with a fixed number of runs.
Syntax
FOR <variable> = <initial value> TO <end value>
...
ENDFOR
Significance
FOR: Initiates the count loop.
ENDFOR: Marks the end of the loop and results in a return jump to the beginning
of the loop, as long as the end value of the count has still not been
reached.
Count variable, which is incremented from the initial to the end value
and is increased by the value "1" at each run.
<variable>:
Type INT or REAL
Note:
The REAL type is used if R parameters are programmed for a
count loop, for example. If the count variable is of the REAL
type, its value is rounded to an integer.
<initial value>: Initial value of the count
Condition: The start value must be lower than the end value.
<full-scale
value>
:
End value of the count
Examples
Example 1: INTEGER variable or R parameter as count variable
INTEGER variable as count variable:
Program code Comments
DEF INT iVARIABLE1
R10=R12-R20*R1 R11=6
FOR iVARIABLE1 = R10 TO R11 ; Count variable = INTEGER variable
R20=R21*R22+R33
ENDFOR
M30