# O-code Repeat

Instructions · `repeat` · verification: source checked

The O-code repeat is a flow-control instruction for NC programs. It executes the statements between a matching repeat and endrepeat a specified number of times. The same O-number labels both the repeat and endrepeat lines.

## Specification

| Property | Value |
|---|---|
| Language | gcode |
| Code | repeat |
| Group | flow control |
| Syntax | o103 repeat [5] ... o103 endrepeat |
| Dialect | rs274ngc |

## Study notes

- O-codes use the letter O, not the digit zero, as the first character, such as O100 or o100.
- The repeat count is shown in square brackets in the example o103 repeat [5].
- The example uses repeat/endrepeat to mill 5 diagonal shapes starting at the present position.
- The repeat and endrepeat lines share the same O-number label.
- A label on endrepeat that does not refer to a corresponding repeat causes an error message and aborts the interpreter.

## Sources

1. [O Codes](https://linuxcnc.org/docs/html/gcode/o-code.html#ocode:repeat) (accessed 2026-10-26)

---

Source page: https://machineschema.com/instruction/ocode-repeat  
JSON: https://machineschema.com/instruction/ocode-repeat.json  
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Cite Machine Schema and the original sources.
