HP (Hewlett-Packard) NW280AAABA Calculator User Manual


 
512 Programming in HP PPL
variables is given in chapter 22, “Variables”, beginning
on page 423.)
In a program you can declare variables for use only within
a particular function. This is done using a LOCAL
declaration. The use of local variables enables you to
declare and use variables that will not affect the rest of the
calculator. Local variables are not bound to a particular
type; that is, you can store floating-point numbers,
integers, lists, matrices, and symbolic expressions in a
variable with any local name. Although the system will
allow you to store different types in the same local
variable, this is poor programming practice and should
be avoided.
Variables declared in a program should have descriptive
names. For example, a variable used to store the radius of
a circle is better named RADIUS than VGFTRFG. You are
more likely to remember what the variable is used for if its
name matches its purpose.
If a variable is needed after the program executes, it can
be exported from the program using the EXPORT
command. To do this, the first command in the program
(that is, on a line above the program name) would be
EXPORT RADIUS. Then, if a value is assigned to
RADIUS, the name appears on the variables menu (
a)
and is visible globally. This feature allows for extensive
and powerful interactivity among different environments in
the HP Prime. Note that if another program exports a
variable with the same name, the most recently exported
version will be active.
The program below prompts the user for the value of
RADIUS, and exports the variable for use outside the
program.
EXPORT RADIUS;
EXPORT GETRADIUS()
BEGIN
INPUT(RADIUS);
END;