Stopping A Program For Keystroke Input; Using Wait For Keystroke Input; Using Key For Keystroke Input; Output - HP 48gII Advanced User's Reference Manual

Graphing calculator
Hide thumbs Also See for 48gII:
Table of Contents

Advertisement

Stopping a Program for Keystroke Input

A program can stop for keystroke input — it can wait for the user to press a key. You can do this with the WAIT
and KEY commands.

Using WAIT for Keystroke Input

The WAIT command normally suspends execution for a specified number of seconds. However, you can
specify that it wait indefinitely until a key is pressed.
To enter WAIT in a program:
To stop without changing the display, enter 0 and the WAIT command (PRG IN menu).
!
To stop and display the current menu, enter –1 and the WAIT command (PRG IN menu).
!
WAIT takes the 0 or –1 from level 1, then suspends execution until a valid keystroke is executed.
For an argument of –1, WAIT displays the currently specified menu. This lets you build and display a menu of
user choices while the program is paused. (A menu built with MENU or TMENU is not normally displayed until
the program ends or is halted.)
When execution resumes, the three-digit key location number of the pressed key is left on the stack. This
number indicates the row, column, and shift level of the key.
To respond to WAIT while running a program:
Press any valid keystroke. (A prefix key such as !or ~ by itself is not a valid keystroke.)
!

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 test-clause sequence, enter the KEY command (PRG IN menu) plus any necessary test commands.
3. In the loop-clause, 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 two-digit row-column number of the pressed key to level 2. For example, `returns 105,
and ! returns 81.)
The test-clause should normally cause the loop to repeat 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 1-21
and "Using Comparison Functions" on page 1-11.)
To respond to a KEY loop while running a program:
Press any key. (A prefix key such as !or ~is a valid key.)
!
The following program segment returns 1 to level 1 if + is pressed, or 0 to level 1 if any other
Example:
key is pressed:
« ... DO UNTIL KEY END 95 SAME ... »

Output

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

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

49g+

Table of Contents