1-38 RPL Programming
Using INPUT … ENTER for Input
INPUT lets you use the stack area for prompting, lets you supply default input, and prevents the user from using
normal stack operations or altering data on the stack.
To enter INPUT in a program:
1. Enter a string (with II delimiters) to be displayed as a prompt at the top of the stack area.
2. Enter a string or list (with delimiters) that specifies the command-line content and behavior — see below.
3. Enter the INPUT command (PRG IN menu).
4. Enter OBJ" (PRG TYPE menu) or other command that processes the input as a string object.
!"!… Iprompt-stringI!Icommand-lineI!6=25:!LS_#!…!1!
or
!"!… Iprompt-stringI!fcommand-lineh!6=25:!LS_#!…!1!
INPUT, in its simplest form, takes two strings as arguments — see the list of additional options following.
INPUT blanks the stack area, displays the contents of the level-2 string at the top of the stack area, and displays
the contents of the level-1 string in the command line. It then activates Program-entry mode, puts the insert
cursor after the string in the command line, and suspends execution.
When execution resumes, the input is returned to level 1 as a string object, called the result string.
To respond to INPUT while running a program:
1. Enter your input. (You can't execute commands — they're simply echoed in the command line.)
2. Optional: To clear the command line and start over, press −.
3. Press `.
If you execute this program segment
! "!IN$jt$%u)!G$o)bI!IlNBKlI!6=25:!1!
the display looks like this:
The following program, VSPH, calculates the volume of a sphere. VSPH prompts for the radius of the sphere,
then cubes it and multiplies by
4
/
3
π. VSPH executes INPUT to prompt for the radius. INPUT sets Program-
entry mode when program execution pauses for data entry.