Concept Flow - Variables (#1, #2) in programs
Start Program
Assign #1 = 10
Assign #2 = 20
Use #1 and #2 in commands
Program Ends
The program starts by assigning values to variables #1 and #2, then uses these variables in commands before ending.
O1000; #1=10; #2=20; G01 X#1 Y#2 F100; M30;
| Step | Action | Variable #1 | Variable #2 | Command Output |
|---|---|---|---|---|
| 1 | Start program | undefined | undefined | No movement |
| 2 | Assign #1=10 | 10 | undefined | No movement |
| 3 | Assign #2=20 | 10 | 20 | No movement |
| 4 | Execute G01 X#1 Y#2 F100 | 10 | 20 | Move to X=10, Y=20 at feed 100 |
| 5 | Execute M30 (program end) | 10 | 20 | Program stops |
| Variable | Start | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|
| #1 | undefined | 10 | 10 | 10 |
| #2 | undefined | undefined | 20 | 20 |
Variables #1 and #2 store numeric values. Assign with #1=10; #2=20; Use in commands like G01 X#1 Y#2; Variables must be assigned before use. They help reuse values and make programs flexible.
#1 and #2 in CNC programs?#1 in a CNC program?#1 := 50.#1 = 10
#2 = 5
G01 X#1 Y#2
G01 X#1 Y#2, resulting in G01 X10 Y5.#1 = 20
#2 30
G01 X#1 Y#2
#1 and #2 for this?G01 X#1 Y#2 to move tool to X=15 and Y=25 using variables.Pass the test and this pattern moves unknown