HP (Hewlett-Packard) NW280AAABA Calculator User Manual


 
Programming 511
The HP Prime programming language
Variables
and visibility
Variables in an HP Prime program can be used to store
numbers, lists, matrices, graphics objects, and strings. The
name of a variable must be a sequence of alphanumeric
characters (letters and numbers), starting with a letter.
Names are case-sensitive, so the variables named
MaxTemp and maxTemp are different.
The HP Prime has built-in variables of various types, visible
globally (that is, visible wherever you are in the
calculator). For example, the built-in variables A to Z can
be used to store real numbers, Z0 to Z9 can be used to
store complex numbers, M0 to M9 can be used to store
Matrices and vectors, and so on. These names are
reserved. You cannot use them for other data. For
example, you cannot name a program M1, or store a real
number in a variable named Z8. In addition to these
reserved variables, each HP app has its own reserved
variables. Some examples are Root, Xmin, and
Numstart. Again, these names cannot be used to name
a program. (A full list of system and app variables is given
in chapter 22, “Variables”, beginning on page 427.)
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