INLIST is an INFORM replacement, having all these same features:
o Editing (including a CALC mode for stack calculations)
o Optional "reset values"
o Optional object type restriction
But INLIST is not limited
to what can be crammed into one small form,
because its "form" is open-ended and *scrolls* vertically.
The INLIST arguments are similar to INFORM:
"Title" { prompts } { initial values }
-OR-
"Title" { prompts } { reset values } { initial values }
Note: Lists other than "prompts"
may be empty or shorter than the "prompts" list.
Each "prompt" in the list of prompts is:
o "Any string" (or any word)
-OR-
o A list: { "Prompt" type1 type2 .. } for object type restriction
How to enter data using INLIST:
Highlight any item; press OK or ENTER to edit.
Individual value "reset" is invoked
by a blank edit area (press ON once if not yet blank).
Individual value CALC mode is invoked
by typing only an "equal" command [=] into the edit area
(left-shifted zero on 48G, right-shifted W on 49G/50G);
return from CALC mode via CONT (left-shifted ON).
Also use CALC mode to see the list of valid object TYPES.
"Reset All" is invoked
by an item at the very end of the form.
"<DONE>" provides the normal exit from INLIST;
ON or "Cancel" (from the form level) aborts.
Level | Stack at normal exit: | Stack after abort:
2: { final values } |
1: 1. | 0.
The use of a full-screen CHOOSE program can improve INLIST,
by displaying a full line for each item,
and by using the full height of the screen.
Full-screen CHOOSE for any HP48G/49G/50G series calculator:
http://groups.google.com/group/comp.sys.hp48/msg/8888908f27145901?dmode=source
http://www.hpcalc.org/details.php?id=6431 (ROLDXJ, contains binaries)
A program INFORML is also provided below,
which accepts the exact same five arguments as INFORM,
but calls INLIST instead, so that you may merely
change INFORM to INFORML in your existing programs that use INFORM.
A program INLISTF is also provided below,
which accepts the fewer arguments needed by INLIST,
but calls INFORM instead, so that you may merely
change INLIST to INLISTF in existing programs that use INLIST.
If you require all form fields to be filled in,
to avoid any skipped fields returning NOVAL as their value,
programs INLISTN and INFORMN are also provided,
which accept the identical arguments, but automatically
repeat INLIST or INFORM until the results are free of any NOVAL.
---
A much simpler way to invite input is provided by INMENU,
which eliminates the complex form (and complex programming),
in favor of a simple menu, where your menu labels indicate
the variables you expect, and a single touch of a menu key
stores a value into its respective variable,
where it can not only be re-used in as many formulas as desired,
but remains stored, so that repeated invocations
do not require re-entry of previously saved values.
The most trivial sort of input is provided by INPROMPT,
to which you supply one message and accept one value at a time.
---
@ Sample program for INPROMPT:
\<< "Enter X" INPROMPT "X" \->TAG
"Enter Y" INPROMPT "Y" \->TAG \>> 'tinp'
@ INPROMPT (all HP48/49/50)
\<< 10. CHR + "then press menu key" + @ optional hint
{ { "OK" \<< 0. MENU CONT \>> }
{ "(AN(L" \<< 0. MENU KILL \>> } }
TMENU PROMPT \>> 'INPROMPT' STO
@ ---
@ Sample program for INMENU:
\<< "Value [menu key]" { X Y } INMENU
X "X" \->TAG Y "Y" \->TAG
'X+Y' EVAL "X+Y" \->TAG
'X*Y' EVAL "X*Y" \->TAG \>> 'tinm'
@ INMENU (48G/49G/50G) store input to variables instead of stack
@ Args: "Title" { labels } Nothing returned on stack.
@ "One touch" to store, DONE returns, LeftShift DONE aborts,
@ RightShift recalls, RightShift CursorDown reviews values.
@ "Real" numbers stored into "unit" objects preserve the units!
\<< { @ the next line is an optional tweak for up to 5 variables
{ "SHOW" \<< #A300Eh RCLF SIZE 3. < 2. * + LIBEVAL \>> }
{ "DONE" { \<< 0. MENU CONT \>> \<< 0. MENU KILL \>> } } } +
TMENU RCLF SIZE 3. > #25EFFh #151A6h IFTE SYSEVAL PROMPT \>>
'INMENU' STO
@ Caution: First back up memory! Incorrect SYSEVALs are harmful!
@ Also note the difference between LIBEVAL and SYSEVAL
@ ---
@ Test program for INLIST[N]:
\<< "Test INLIST"
{ { "Set VX to" 6. } { "Any Number" 0. 28. } "Required field" }
{ X 123 } DUP INLIST \>> 'tinl' @ or INLISTN to avoid NOVAL
@ Note that INFORM would throw an error on type code 28
@ Complete INLIST (in UserRPL) for HP48G/49G/50G
\<< 3. PICK TYPE 2. == { { } SWAP } IFT @ Omitted resets?
3. PICK 1. \<< DROP NOVAL \>> DOSUBS @ Pad values lists
1. DUP2 6. ROLL REPL 4. ROLLD ROT REPL @ To match prompts
0. RCLF { GET DUP TYPE 2. == { 34. CHR SWAP OVER + + }
IFT DUP NOVAL SAME { DROP "" } IFT \->STR } RCLMENU \-> h.
p. b. a. n. f. c. m. \<< -55. SF 64. STWS STD DO IF h. p.
@ Build a new CHOOSE list (showing current values):
1. \<< { } + 1. GET "=" + a. NSUB c. EVAL + NSUB 2. \->LIST
\>> DOSUBS { "<DONE>" "[Reset All]" } + 'n.' INCR
@ Exit or "reset all" if either was selected:
CHOOSE THEN DUP 'n.' STO IF TYPE THEN IF n. " " POS THEN
b. 'a.' STO 0. DUP 'n.' STO ELSE a. 1. 1. END ELSE
@ Get the prompt and current value for INPUT (editor):
p. n. GET { } + 1. GET \->STR a. n. c. EVAL 28. MENU
IFERR INPUT "{" SWAP + STR\-> DUP SIZE 1. > { DROP 7. DOERR }
@ Reset if null input, halt for CALC if "equal" command:
IFT LIST\-> NOT { b. n. GET } IFT { = } OVER POS { DROP
DEPTH \->LIST a. n. GET RCLF \-> s. v. g. \<< p. n. GET
{ } + TAIL DUP SIZE NOT { { ALL } + } IFT "Types" \->TAG
f. STOF v. HALT g. STOF DEPTH NOT { v. } IFT DEPTH ROLLD
DEPTH 1. - DROPN s. LIST\-> DROP DEPTH ROLL \>> } IFT
@ Object type restrictions:
DUP NOVAL SAME NOT { p. n. GET { } + TAIL DUP SIZE
{ 0. ADD OVER TYPE POS NOT { DROP 7. DOERR } IFT }
{ DROP } IFTE } IFT @ Okay @ 'a.' n. ROT PUT THEN
ERRN B\->R { "Invalid object or type" MSGBOX } IFT
'n.' DECR DROP END m. TMENU 0. END
ELSE 0. 1. END UNTIL END f. STOF \>> \>> 'INLIST' STO
@ Auxiliary programs:
@ Loop on INLIST until no undefined value (NOVAL) in results
@ [takes the same args as INLIST]
\<< 3. PICK TYPE 2. == { { } SWAP } IFT 4. ROLLD \->
t. p. b. \<< 1. DO DROP t. p. b. 4. ROLL INLIST DUP DUP
{ DROP OVER NOVAL POS } IFT UNTIL NOT END \>> \>> 'INLISTN' STO
@ Loop on INFORM until no undefined value (NOVAL) in results
@ [takes the same args as INFORM]
\<< 5. ROLLD \-> t. p. f. b. \<< 1. DO DROP t. p. f. b.
5. ROLL INFORM DUP DUP { DROP OVER NOVAL POS } IFT
UNTIL NOT END \>> \>> 'INFORMN' STO
@ This takes args for INFORM, but calls INLIST instead
\<< ROT DROP ROT 1. \<< { } + DUP SIZE { DUP HEAD SWAP TAIL TAIL
+ } { DROP } IFTE \>> DOSUBS ROT ROT INLIST \>> 'INFORML' STO
@ This takes args for INLIST, but calls INFORM instead
\<< 3. PICK TYPE 2. == { { } SWAP } IFT ROT 1. \<< { } +
DUP HEAD "" + { "" } + SWAP TAIL + \>> DOSUBS DUP SIZE
DUP 4. MIN / CEIL 4. ROLL 4. ROLL INFORM \>> 'INLISTF' STO
@ [This is the end]