Master Haas CNC M97 Local Sub-Program Calls: Step-by-Step Example
Almost every cnc controls has a way to make subprograms, subroutines.
CNC Subprograms are added to cnc program memory (cnc program directory) as separate cnc programs which are then called from an outside cnc program (main-program).
Read more about CNC Subprograms
- CNC Subprograms Basics for CNC Machinists
- Fanuc Sub Programming
- Fanuc Subprogram Example

Haas CNC
Haas CNC Local SubPrograms
Haas CNC supports normal cnc sub-programming commands M98, M99.
But Haas CNC gives a lot more and manageable way to make subprograms (subroutines), called Local Sub-Programs.
Haas cnc local subprograms are not added as separate cnc programs to cnc programs memory.
But Haas cnc local subprograms are added (at end) to the main-program or calling program.
So Haas cnc local subprograms are part of the main-program.
How to Call Haas CNC Local SubProgram
Haas cnc local subprograms are called with M97 command.
Haas CNC Local Subprogram Call M97 FormatM97 P… L…
P – A line number within same program (Subprogram must end with M99).
L – Number of subprogram repetitions.
Haas CNC Local Subprogram Example
O0001 M97 P1000 L2 (L2 command will run the N1000 line twice) M30 N1000 G00 G90 G55 X0 Z0 (N line that will run after M97 P1000 is run) S500 M03 G00 Z-.5 G01 X.5 F100. G03 Z... G01 X0 Z1. F50. G91 G28 X0 G28 Z0 G90 M99
CNC Machine
- Fanuc G20: Mastering Inch-Based CNC Programming – Practical Example
- Mastering C‑Axis Lathe Programming with Live Tooling on Haas CNC
- Haas CNC G71 Bolt Hole Arc Command – Practical Example for Efficient Hole Drilling
- Haas M98 Subprogram Call: Practical Guide & Sample Code
- CNC Programming Fundamentals: Step‑by‑Step Tutorials & Sample Code
- Haas G150 Pocket Milling Example: CNC Program for a Square Pocket with Island
- Haas G150 Pocket Milling Example: Precision Round Island Machining
- CNC Subprogram Tutorial: Using G91 Incremental Mode for Precise Z‑Axis Control
- Mastering Haas CNC Circular Interpolation: Practical G02/G03 Programming & Examples
- Efficient CNC Lathe Subprogram Calls for Repeated Pattern Cutting