CNC mill · M-code
M97: local subprogram call
M97 calls a subprogram inside the same program, by its line number. Format below from Haas, its maker. LinuxCNC has no such code.
Worked example
Run the N100 subprogram four times. Written for this page in the Haas format.
M97 P100 L4 (calls N100 four times)M30N100 (subprogram)(… moves …)M99 (back to the main program)How each control writes it
Haas M97 P- L-
One source: Haas Automation, the control's maker
- P
- Line number (N) of the subprogram in this program
- L
- Repeat the call 1–99 times (optional)
- The subprogram sits after the M30 and ends with M99.
- Useful for short subprograms that don’t need their own program number.
Source: Haas Automation, mill M97
Controls without it
- LinuxCNC: LinuxCNC has no M97. A subroutine in the same file runs from o100 sub to o100 endsub and is called with o100 call. Source (archived Nov 10, 2026)
No Fanuc row yet: that chapter of the 0i manual has not been read.
Haas follows Fanuc's numbering, but options and parameters differ between controls: check your control's manual.