Nesting, Nesting depth, Subprogram in a subprogram – HEIDENHAIN TNC 360 User Manual User Manual
Page 132: 4 nesting
6-9
TNC 360
6
Subprograms and Program Section Repeats
.
.
.
.
.
.
.
.
.
3
4
2
.
.
.
5
1
.
.
.
Subprogram 1
with program call of
subprogram 2
Subprogram 2
6.4 Nesting
Subprograms and program section repeats can be nested in the following
variations:
• Subprograms in subprograms
• Program section repeats in program section repeats
• Subprograms can be repeated
• Program section repeats can appear in subprograms
Nesting depth
The nesting depth is the number of successive levels for which subpro-
grams or program sections can call further subprograms or program
sections.
Maximum nesting depth for subprograms: 8
Maximum nesting depth for calling main programs: 4
Subprogram in a subprogram
Program layout
0
BEGIN PGM 360069 MM
e.g. 17
CALL LBL 1 .............................................. Call of subprogram at LBL1
e.g. 35
L Z+100 R0 FMAX M2 ............................. Last program block of 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 360069 MM ............................ End of main program
Sequence of program execution
Step 1:
Main program 360069 is executed up to block 17.
Step 2:
Subprogram 1 is called and executed up to block 39.
Step 3:
Subprogram 2 is called and executed up to block 62.
End of subprogram 2 and return to subprogram from
which it was called.
Step 4:
Subprogram 1 is executed from block 40 to block 45.
End of subprogram 1 and return to main program 360069.
Step 5:
Main program 360069 is executed from block 18 to block 35.
Return jump to block 1 and program end.
A subprogramm ending with LBL 0 must not be nested in another subprogram!