The O-code conditional is a flow-control block in LinuxCNC NC programs. A group of statements shares one O-number, begins with if, may include elseif and else sections, and ends with endif. The interpreter executes the first branch whose condition is true; if no if or elseif condition is true, it executes the else statements.
| Language | gcode |
|---|---|
| Code | if |
| Group | Conditional |
| Syntax | Onnn if [condition] ... Onnn elseif [condition] ... Onnn else ... Onnn endif |
| Dialect | LinuxCNC |
| Name | Description |
|---|---|
| O-number | Number used after O; the same number must be used for the if, any elseif or else, and endif statements in the group. |
| condition | Expression in square brackets after if or elseif; evaluated to true or false to choose the branch. |