beautypg.com

HP Prime Graphing Wireless Calculator User Manual

Page 298

background image

294

Programming in HP PPL

I/O

I/O commands are used for inputting data into a
program, and for outputting data from a program. They
allow users to interact with programs.

CHOOSE

Syntax: CHOOSE(var, "title", "item1",

"item2",…,"itemn")
Displays a choose box with the title and containing the
choose items. If the user selects an object, the variable
whose name is provided will be updated to contain the
number of the selected object (an integer, 1, 2, 3, …) or
0 if the user taps

.

Returns true (not zero) if the user selects an object;
otherwise, returns false (0).
Example:

CHOOSE
(N,"PickHero",

"Euler","Gauss

","Newton");
IF N==1 THEN

PRINT("You

picked

Euler"); ELSE

IF N==2 THEN PRINT("You picked

Gauss");ELSE PRINT("You picked

Newton");
END;
END;

After execution of CHOOSE, the value of N will be updated

to contain 0, 1, 2, or 3. The IF THEN ELSE command

causes the name of the selected person to be printed to
the terminal.