Radio Shack TRS-80 PC-4 Owner's Manual page 56

Trs-80 pc-4
Hide thumbs Also See for TRS-80 PC-4:
Table of Contents

Advertisement

Nesting
Similar to the FOR-NEXT statement, GOSUB statements can also be stacked. The
number of times the subroutine is called out is fixed.
This nesting can be performed up to 8 levels. Consequently, a subroutine can be called
out from a subroutine.
Main routine
Subroutine
Subroutine
Subroutine
Main routine
1st level
2nd level
3rd level
Subroutine
Subroutine
In this example, the subroutines
are not stacked so you can use
as many as you like.
This example shows three levels of
nesting. Up to 8 levels can
be
stacked.
A subroutine is convenient for assembling common portions of a main routine in order
to save the number of steps or for assembling portions separately as subroutines when
assembling a complicated program.
-53-

Advertisement

Table of Contents
loading

Table of Contents