Working with variables, Using local variables, Setting variables – HP 49g Graphing Calculator User Manual
Page 194: Working with lists -6, Using local variables -8, Setting variables -8
Attention! The text in this document has been recognized automatically. To view the original document, you can use the "Original mode".

Working with variables
You use variables to hold data within your programs. There are two types
of variables within the HP 49G programming environment.
® You create local variables within your program. For example, local
variables hold the values set by the arguments you use when you call
the program.
A program can only access a local variable inside the nested procedure
where it was created, and any nested procediu'es that it contains.
® You can create global variables in a program or you can use existing
global variables. See chapter 7, “Storing objects” for details on how to
create global variables. Note the following points:
-
Global variables are available anywhere within a program.
-
To remove a global variable using code, use the PURGE conuuand.
-
If you use global variables in your program, they must be located in
the same directoiy, or higher, as the program.
Using local variables
There are some constraints with local variables that you need to be aware
of. These are as follows:
® Immediately after a local variable declaration, the program code must
contain either:
-
an algebraic calculation enclosed in single quotes
-
a nested procedure enclosed by « ».
® A local variable is available in the nested procedure where it was
created, and all nested procedures that it contains.
® You can create a local variable with the same name as an existing
global variable (that is, a variable in the same directory or higher as the
program). Commands that use the variable name will use the local
variable value rather than the global variable value.
Setting variables
You generally set variables to inputs or to the results of processes and
calculations that your program performs. You can use local variables to
store intermediate results that you want to re-use in subsequent nested
procedures within your program. Use global variables to store data for
wider access.
Page 10-8
Introduction to programming