
If a variable is needed after the program executes, it can be exported from the program using the EXPORT
command. To do this, the rst 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
( ) and is visible globally. This feature allows for extensive and powerful interactivity among dierent
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;
Note that EXPORT command for the variable RADIUS appears before the heading of the function where
RADIUS is assigned. After you execute this program, a new variable named RADIUS appears on the USER
GETRADIUS
section of the Variables menu.
Qualifying the name of a variable
The HP Prime has many system variables with names that are apparently the same. For example, the
Function app has a variable named Xmin, but so too do the Polar app, the Parametric app, the Sequence app,
and the Solve app. In a program, and in the Home view, you can refer to a particular version of these variables
by qualifying its name. This is done by entering the name of the app (or program) that the variable belongs to,
followed by a dot (.), and then the actual variable name. For example, the qualied variable
Function.Xmin refers to the value of Xmin within the Function app. Similarly, the qualied variable
Parametric.Xmin refers to the value of Xmin in the Parametric app. Despite having the same name
(Xmin), the variables could have dierent values. You do likewise to use a local variable in a program: specify
the name of the program, followed by the dot, and then the variable name.
568 Chapter 28 Programming in HP PPL
Komentarze do niniejszej Instrukcji