beautypg.com

The user keyboard: customizing key presses – HP Prime Graphing Calculator User Manual

Page 519

background image

Programming

515

In this scenario, assume there is no ROLLDIE function

exported from another program. Instead, ROLLDIE is

visible only to ROLLMANY. The ROLLDIE function must be

declared before it is called. The first line of the program
above contains the declaration of the ROLLDIE function.

The definition of the ROLLDIE function is located at the

end of the program.
Finally, the list of results could be returned as the result of
calling ROLLMANY instead of being stored directly in the

global list variable, L2. This way, if the user wanted to
store the results elsewhere, it could be done easily.

EXPORT ROLLMANY(n,sides)
BEGIN
LOCAL k,roll,results;
MAKELIST(0,X,1,2*sides,1)

results;

FOR k FROM 1 TO n DO
ROLLDIE(sides)+ROLLDIE(sides)

roll;

results(roll)+1

results(roll);

END;
RETURN results;
END;

In Home view you would enter ROLLMANY(100,6)

L5

and the results of the simulation of 100 rolls of two six-
sided dice would be stored in list L5.

The User Keyboard: Customizing key presses

You can assign alternative functionality to any key on the
keyboard, including to the functionality provided by the
shift and alpha keys. This enables you to customize the
keyboard to your particular needs. For example, you
could assign

e

to a function that is multi-nested on a

menu and thus difficult to get to on a menu (such as
ALOG).
A customized keyboard is called the user keyboard and
you activate it when you go into user mode.