6 Subprograms and Program Section Repeats
L
6.4 Nesting
Subprograms and program section repeats can be nested in the following
variations:
L
l
Subprograms in subprograms
l
Program section repeats in program section repeats
l
Subprograms can be repeated
l
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
: 9
1
e.g. 17 CALL LBL 1
: 4
5
e.g. 35 L Z+lOO RO FMAX M2
36 LBL 1
: 4 2
e.g. 39 CALL LBL 2
i 4 4
e.g. 45 LBL 0 . . .._...._......_....................................
End of subprogram 1
Call of subprogram at LBLI
Last program block of main program (with M2)
I
Subprogram 1
with program call of
subprogram 2
46 LBLZ
: 4
3
.
e.g. 62 LBLO . . . . _ . . . . . _._ . . . . . . __ . . . . . . . . . . . . . . . . . . . *.. End of subprogram 2
63 END PGM 360069 MM End of main program
Sequence of program execution
Step 1:
Step 2:
Step 3:
Main program 360069 is executed up to block 17.
Subprogram 1 is called and executed up to block 39.
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:
Step 5:
Subprogram 1 is executed from block 40 to block 45.
End of subprogram 1 and return to main program 360069.
Main program 360069 is executed from block 18 to block 35.
Return jump to block 1 and program end.
TNC 370 6-9