Chapter 7
140
UM10350_PCNC770_Manual_0916A
Programming
7.10.1.3 Conditional Subroutines
Subrounes can be condionally executed using the if/endif or the if/else/elseif/endif keyword constructs.
if/endif
The if/endif condional will execute a block of code following theif keyword only when the if
argument evaluates to true.
If/endif Example:
o100 sub
(notice that the if-endif block uses a different number)
o110 if [#2 GT 5]
(some code here)
o110 endif
(some more code here)
o100 endsub
If/elseif/else/endif
The if/elseif/else/endif condional will execute the block of code following the if keyword when its
argument evaluates to true. If the argument evaluates to false, then the code following each elseif is
executed as long as the associated elseif argument evaluates to true. If no elseif keywords are present,
or if all elseif arguments evaluate to false, than the code following the else keyword is executed.
If/elseif/endif example:
o102 if [#2 GT 5] (if parameter #2 is greater than 5 set F100)
F100
o102 elseif [#2 LT 2] (else if parameter #2 is less than 2 set F200)
F200
o102 else (else if parameter #2 is 2 through 5 set F150)
F150
o102 endif
7.10.1.4 Repeating Subroutines
Subrounes can be repeated a nite number of mes using the repeat/endrepeat keyword.
Repeat example:
(Mill 5 diagonal shapes)
G91 (Incremental mode)
o103 repeat [5]
... (insert milling code here)
G00 X1 Y1 (diagonal move to next position)
o103 endrepeat
G90 (Absolute mode)