Using KEY for Keystroke Input

You can use KEY inside an indefinite loop to “pause” execution until any key — or a certain key — is pressed.

To enter a KEY loop in a program

1.Enter the loop structure.

2.In the testclause sequence, enter the KEY command (PRG IN menu) plus any necessary test commands.

3.In the loopclause, enter no commands to give the appearance of a “paused” condition.

KEY returns 0 to level 1 when the loop begins. It continues to return 0 until a key is pressed — then it returns 1 to

level 1 and the twodigit rowcolumn number of the pressed key to level 2. For example, `returns 105, and ! returns 81.)

The testclause should normally cause the loop to r epeat until a key is pressed. If a key is pressed, you can use comparison tests to check the value of the key number. (See “Using Indefinite Loop Structures” on page 122 and “Using Comparison Functions” on page 111.)

To respond to a KEY loop while running a program:

Press any key. (A prefix key such as !or ~is a valid key.)

Example: The following program segment returns 1 to level 1 if + is pressed, or 0 to level 1 if any other key is pressed:

«DO UNTIL KEY END 95 == »

Output

You can determine how a program presents its output. You can make the output more recognizable using the techniques described in this section.

Data Output Commands

Key

Command

Description

 

 

 

!°L%OUT%:

 

 

 

 

%PVIEW%

PVIEW

Displays PICT starting at the given coordinates.

%TEXT%

TEXT

Displays the stack display.

%CLLCD%

CLLCD

Blanks the stack display.

%DISP%

DISP

Displays an object in the specified line.

%FREEZ%

FREEZE

“Freezes” a specified area of the display until a key press.

%MSGBO%

MSGBOX

Creates a userdefined message box.

%BEEP%

BEEP

Sounds a beep at a specified frequency (in hertz, level 2)

 

 

and duration (in seconds, level 1).

 

 

 

RPL Programming 149

Page 73
Image 73
HP 48gII Graphing, 50g Graphing manual Using KEY for Keystroke Input, Data Output Commands, Out%