Loops & Decisions

Repeat work with WHILE/DO instead of copying blocks.

A WHILE [condition] DO1 … END1 block repeats while the condition holds. This is the moment a program stops being a list of moves and starts being software.

Read firstMacro Control FlowReference for CNC macro control flow including conditional branches, conditional execution, and iteration loops.→

Your turn

Your macro is called with a hole count in #1. Using a WHILE loop, count from 0 up to that number in #102, adding each step into a running total in #101. (With 5 holes the total is 0+1+2+3+4 = 10.)

The machine gives you

5 holes:#1 = 5
8 holes:#1 = 8

Your program is run once for each set of conditions. It has to work for all of them.

Loading...

This is a learning simulation — always prove out a program on the actual control before you cut metal.