4 nesting – HEIDENHAIN TNC 407 (280 580) User Manual User Manual
Page 183

6-9
TNC 425/TNC 415 B/TNC 407
6
Subprograms and Program Section Repeats
.
.
.
.
.
.
.
.
.
.
.
.
3
4
2
5
1
.
.
.
6.4 Nesting
Subprograms and program section repeats can be nested in the following
variations:
• Subprograms in a subprogram
• Program section repeats in a program section repeat
• Repeating subprograms
• Program section repeats in a subprogram
Nesting depth
The "nesting depth" is the number of successive levels for which program
sections or subprograms can call further program sections or subpro-
grams.
Maximum nesting depth for subprograms: 8
Maximum nesting depth for calling main programs: 4
Subprogram in a subprogram
Program layout
0
BEGIN PGM SPGMN MM
e.g. 17
CALL LBL 1 .............................................. Call the subprogram marked with LBL1
e.g. 35
L Z+100 R0 FMAX M2 ............................. Last program block of the main program (with M2)
36
LBL 1
e.g.. 39
CALL LBL 2
e.g.. 45
LBL 0 ........................................................ End of subprogram 1
46
LBL 2
e.g. 62
LBL 0 ........................................................ End of subprogram 2
63
END PGM SPGMN MM ........................... End of main program
Program execution
1st Step:
The main program SPGMN is executed up to block 17.
2nd Step:
Subprogram 1 is called and executed up to block 39.
3rd Step:
Subprogram 2 is called and executed up to block 62.
End of subprogram 2 and return jump to the subprogram from which
it was called.
4th Step:
Subprogram 1 is called and executed from block 40 to block 45.
End of subprogram 1 and return jump to the main program SPGMN.
5th Step:
Main program SPGMN is executed from block 18 to block 35.
Return jump to block 1 and end of program.
A subprogram ending with a LBL 0 must not be contained in another subprogram.
Subprogram 1
with program call of
subprogram 2
Subprogram 2