Using local variables within subroutines, Local variables and user-defined functions – HP 48g Graphing Calculator User Manual
Page 424
Attention! The text in this document has been recognized automatically. To view the original document, you can use the "Original mode".
29
want it evaluated—the program should execute EVAL after the object
is put on the stack.
Using Local Variables within Subroutines
Because a program is itself an object, it can be used in another
program as a subroutine. When program B is used by program'
A, program A calls program B, and program 5 is a subrouime in
program A.
Normally, a local variable exists only inside its defining procedure (and
not within any subroutines called by the defining procedure). Thus,
normal local variables can only be used within a subroutine if the
subroutine is embedded, or nested within the local variable’s defining
procedure.
However, the HP 48 offers a way to include local variables in
subroutines that are not nested within the local variable’s defining
procedure.
To- use a ioca! ¥sriabie
I n a
subroutine called t// l!ie ¥ariabie’'s
■tiefining procedure:
B When defining the local variable, name it using -e
as the
first character. This creates a compiled local variable.
m When calling the local variable within a subroutine, specify its name
using as the first character.
A compiled local variable is available to any subroutine called by the
defining procedure for the local variable. How^ever, compiled local
variables are still local variables and are purged when the defining
procedure is completed.
Local Variables and User-Defined Functions
The defining procedure for a local variable structure can be either an
algebraic or program object.
A user-defined function is actually a program that consists solely of
a local variable structure whose defining procedure is a an algebraic
expression. The syntax is:
name^ name2
name„ 'expression
29-18 Programming the HP 48