beautypg.com

Smithy CNC Mills User Manual

Page 44

background image

4.2 Looping: "do", "while", "endwhile", "break", "continue"

The "while loop" has two structures: while/endwhile, and do/while. In each

case, the loop is exited when the "while"condition evaluates to false.

(draw a sawtooth shape)

F100

#1 = 0

O101 while [#1 lt 10]

G1 X0

G1 Y[#1/10] X1

#1 = [#1+1]

O101 endwhile

Inside a while loop, O- break immediately exits the loop, and O- continue imme-

diately skips to the next evaluation of the while condition. If it is still true,

the loop begins again at the top. If it is false, it exits the loop.

4.3 Conditional: "if", "else", "endif"

The "if" conditional executes one group of statements if a condition is true and

another if it is false.

(Set feed rate depending on a variable)

O102 if [#2 GT 5]

F100

O102 else

F200

O102 endif

4.4 Indirection

The O- value may be given by a parameter or calculation.

O[#101+2] call

SmithyCNC Programmer’s Reference Manual: O Codes

4-3