# Global And Local Variables And Subprograms - HP 50g User Manual

Graphing calculator.

/
~„x™
[']
„°@) @ MEM@@ @) @ DIR@@ @PURGE
`
_______________________
To save the program use: [']~„gK
Press J to recover your variable menu, and evaluate g(3.5) by entering the
value of the argument in level 1 (3.5`) and then pressing @@@g@@@.
The result is 1.2485..., i.e., g(3.5) = 1.2485. Try also obtaining g({1 2 3}), by
entering the list in level 1 of the display: „ä1#2#3`
and pressing @@@g@@@. The result now is {SINH(1)/2 SINH(2)/5 SINH(3)/10}, if
result will be {0.5876.. 0.7253... 1.0017...}.

## Global and local variables and subprograms

The program @@@g@@@, defined above, can be displayed as
«
by using ‚@@@g@@@.
Notice that the program uses the variable name x to store the value placed in
level 1 of stack through the programming steps
the program is executing, is stored in your variable menu as any other variable
you had previously stored. After calculating the function, the program purges
(erases) the variable x so it will not show in your variable menu after finishing
evaluating the program. If we were not to purge the variable x within the
program its value would be available to us after program execution. For that
reason, the variable x, as used in this program, is referred to as a global
variable. One implication of the use of x as a global variable is that, if we had
a previously defined a variable with the name x, its value would be replaced by
the value that the program uses and then completely removed from your
From the point of view of programming, therefore, a global variable is a
variable that is accessible to the user after program execution. It is possible to
/
'x'
PURGE
__________
mode. If your CAS is set to APPROXIMATE mode, the
EXACT
'x' STO x SINH 1 x SQ ADD / 'x' PURGE
Calculate (1+x
then divide
Purge variable x
Program in level 1
_____________________
. The variable x, while
'x' STO
2
),
"
Page 21-2