Nested procedures, Nested procedures -7 – HP 49g Graphing Calculator User Manual
Page 193
Attention! The text in this document has been recognized automatically. To view the original document, you can use the "Original mode".

You can run other programs from within your programs. In this manner,
you can create modular programs. For example, you could create three
discrete component programs named INPUT, PROCESSING, and
OUTPUT. You could then create a master program that rims each of these
components in tiun, as follows:
« INPUT PROCESSING OUTPUT »
Nested procedures
If you use local variables to collect input arguments, you need to use
nested procedures if you want to perfonn branching and looping. You
cannot perform branching and looping from within an algebraic object.
To insert a new nested procedure in your code, press 0(Eu) to insert tire
delimiters. Enter the procedure code between the delimiters.
For example, in the following programming segment, the input argiunents
are assigned to variables A and B. The algebraic object, a calculation that
adds the variables, needs to be enclosed in single quotes as it immediately
follows the local variable definition. This example returns the sum of A
and B to the history.
« —^ A B ' A+B' »
In the following programming segment you use a nested procedure, as the
processing involves more than a simple calculation. This example
compares A and B, and carries out calculations based on the comparison.
The results of the calculations are stored in global variables C and D.
« ^ A B
«IF A>B
THEN A-B k C; A^2-B^2 k D
ELSE B-A k C
END
Note that within a nested procedure, you need to use ; to
separate calculations. To insert a ; character, press and hold
0
and press (S0.
Introduction to programming
Page 10-7