Using local variables, Using local variables -16, Creating local variables – HP 48g Graphing Calculator User Manual
Page 422
Attention! The text in this document has been recognized automatically. To view the original document, you can use the "Original mode".
29
Using Local Variables
There are disadvantages to using global variables in programs:
■ After program execution, global variables that you no longer need
to use must be purged if you want to clear the VAR menu and free
user memory.
■ You must explicitly store data in global variables prior to program
execution, or have the program execute STO.
Local variables address the disadvantages of global variables in
programs. Local variables are temporary variables created by a
program. They exist only while the program is being executed and
cannot be used outside the program. They never appear in the VAR
menu. In addition, local variables are accessed faster than global
variables. (By convention, this manual uses lowercase names for local
variables.)
Creating Local Variables
In a program, a local variable structure creates local variables.
To enter a local warlable structyre ¡n a program:
1. Enter the command (press
2. Enter one or more variable names.
3. Enter a defining procedure (an algebraic or program object) that
uses the names.
or
narnei iiame
2
namei name
2
namCn ' algebraic '
namcn V. program
When the command is executed in a program, n values are taken
from the stack and assigned to variables namei, name
2
, ■ .. name^.
For example, if the stack looks like this;
29-16 Programming the HP 48