Global variable scope – HP 48gII User Manual

Page 653

Advertising
background image

Page 21-4

«

→ x

«

x SINH 1 x SQ ADD /

»

»

.

When done editing the program press

` . The modified program is stored

back into variable

@@g@@.

Global Variable Scope

Any variable that you define in the HOME directory or any other directory or
sub-directory will be considered a global variable from the point of view of
program development. However, the scope of such variable, i.e., the location
in the directory tree where the variable is accessible, will depend on the
location of the variable within the tree (see Chapter 2).

The rule to determine a variable’s scope is the following: a global variable is
accessible to the directory where it is defined and to any sub-directory
attached to that directory, unless a variable with the same name exists in the
sub-directory under consideration. Consequences of this rule are the following:

• A global variable defined in the HOME directory will be accessible from

any directory within HOME, unless redefined within a directory or sub-
directory.

• If you re-define the variable within a directory or sub-directory this

definition takes precedence over any other definition in directories above
the current one.

• When running a program that references a given global variable, the

program will use the value of the global variable in the directory from
which the program is invoked. If no variable with that name exist in the
invoking directory, the program will search the directories above the
current one, up to the HOME directory, and use the value corresponding
to the variable name under consideration in the closest directory above
the current one.


A program defined in a given directory can be accessed from that directory
or any of its sub-directories.


Advertising
This manual is related to the following products: