Thanks
Frustrated User
There are many ways of doing this, and which you use is a matter of
taste, I suppose.
Method 1:
<< "Height?" PROMPT 'H' STO ...
This displays a user prompt and halts the program. The user then types
in a value, and presses CONT (left-shift ON) to continue. This is the
simplest to program, but the least friendly to use.
Method 2:
<< "Height"? ":H: " INPUT STR-> 'H' STO ...
This displays both a user prompt and the name of the variable. The user
types in a value, and presses ENTER to continue. The :H: tag is
automatically stripped off the input by the STO command. This method
has many powerful options (see the AUR or the FAQ), but is also easy to
program, and is very friendly to the user.
Method 3:
Create an input form with the INFORM command. Painfully complicated
to program, and it runs slowly, but it's the most friendly to the user.
See the AUR and/or the FAQ for details.
Method 4:
Create a temporary menu with the TMENU command, and let the user input
the variables shown there in whatever order he pleases, and then press
the GO! menu key to continue. When the name of the variable (or a
very short prompt!) is enough, this is the power-user's favorite input
interface.
Method 5:
If there are only a few meaningful inputs, create a CHOOSE box and offer
only those options to the user.
Hope this helps! (Hey, folks: are there any other input methods?)
-Joe-
Sent via Deja.com http://www.deja.com/
Before you buy.
[ways to ask for input of a program]
>Hope this helps! (Hey, folks: are there any other input methods?)
I once tried to help a carpenter who needs to calculate all day long
the same simple equations, where for the next calculation one/some or
all numbers change. The easiest to use way we came up with was this
solution which uses the SOLVR routine to build inverse menus to tell
the user that pressing this key will store the value from level 1 into
that specific variable. I post the little program as an example.
Program itself:
%%HP: T(3);
\<<
{ { } {
{ O \<< 'O' STO see \>> }
{ P \<< 'P' STO see \>> }
{ W \<< 'W' STO see \>> }
{ H \<< 'H' STO see \>> }
{ L \<< 'L' STO see \>> }
CONT KILL }
} STEQ
30 MENU see HALT W H - P 2 * -
'B' \->TAG O W - L - P -
'T' \->TAG W P - 'U' \->TAG
HALT PR
\>>
change
KILL
to
{ "BACK" << KILL 2 MENU >> }
to KILL the program running and
return to the VARS menu automatic
(other numbers in appendix C for other MENUs)
Routine which has to be named: see
so that the main program can call it
%%HP: T(3);
\<<
CLLCD
"O " O \->STR + 1 DISP 3 FREEZE
"P " P \->STR + 2 DISP 3 FREEZE
"W " W \->STR + 3 DISP 3 FREEZE
"H " H \->STR + 4 DISP 3 FREEZE
"L " L \->STR + 5 DISP 3 FREEZE
\>>
The use:
*Start the program
*change values, by just typing a value in and press the corresponding
key (like in the SOLVR) to store the value. Then automatic you'll have
an updated screen showing all current values!
*change values as long as neccessary, then press CONT, that will
calculate the three unknowns and output them tagged to the stack.
(Older contents of the stack will roll up).
*pressing CONT next time will again show you the current values and
give you the choice if you'd like to change any vars.
*End the program via the KILL key on the next page
Greetings from Cologne
Peter
_______________________________
Do you know the great Frequently Asked Questions?
http://www.engr.uvic.ca/~aschoorl/faq/
and the superb HP48 Software Archive?
http://www.hpcalc.org
to look for *old* HP48 postings see
http://www.deja.com
"enter inst. height"
{ ":HI: 5.20" { 1 0 } v }
INPUT
The second time I use the program I want it to use the same value
that I entered previously for HI and put the cursor at the beginning
of the number so that I can change it quickly or hit enter to accept
the
default value of 5.20 or whatever the number may be.
Can this be done ? The key thing is to have the default value
be the same as it was entered the last time the program was run.
And the cursor starting at the first digit of the number.
"enter inst.height"
5:
4:
3:
2:
:HI: 5.20
J.K.H "You'r the man" :)
I have learned a lot from reading your posts
and I for one appreciate the time that you have taken to help
us ocassional programers.
TIA -Martin-
"Joseph K. Horn" wrote:
Method 1:
Method 2:
Method 3:
Method 4:
Method 5:
Hope this helps! (Hey, folks: are there any other input methods?)
-Joe-
INP:
<< "Enter inst. height"
":HI:" HI + { -5 V } +
INPUT
OBJ-> 'HI' STO >>
HI is the variable, where your INPUT-result is stored in. To execute the
program,
the Variable has to exist already.
Next time you call INP your stored value will be displayed, ready to alter.
If you cancel the INPUT-command by pressing ON twice, there will be rubbish
on the stack.
I hope, that this helps.
Greetings from Joachim Stump.
martin & laurie Etcheverry schrieb in Nachricht
<37FDA579...@maui.net>...
>
> --------------B0882F4CE8B12DC44026F075
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> I have been trying to use input to ask for user input and have a taggged
> default value on the command line that dynamically changes and also allows
> for
> input options.
>
> This is not what I want!
>
> "enter inst. height"
> { ":HI: 5.20" { 1 0 } v }
> INPUT
Hehe, so programming another data collector, eh? :)
Since the input you want is clearly defined (you want a real
number, and a _single_ real number), I suggest that you get better
control over the result. Either use an input form (INFORM), where you
could possibly combine this input value with something else (for
example, 'target height', or 'station name'), or use a couple of my
small libraries which essencially provide an extension to the UserRPL
command set -- been there done that, that's why I'm recommending them
to you :)
Now for the examples:
Let's assume that you have your instr. height in a global variable
called 'IH' -- in the real world, you don't want to do that, but
that's another story
Method 1. INFORM
\<<
'IH' VTYPE -1 == @ If 'IH' doesn't exist
\<< 0 'IH' STO @ Create it, assign 0 to it.
\>> IFT
"Enter instr. height"
{ @ Field definitions
{ } @ leave a blank line
{ "IH" "Instrument height (in meters)" 0 } @ tag, help txt, type
} @ End filed definitions
{ } @ Formats
{ } @ Reset values.
IH 1 \->LIST @ Initial value
INFORM
\<< @ If OK'ed
HEAD 'IH' STO @ store new value into IH
\>>
\<< @ If CANCELed
"Value not changed. IH=" IH +
MSGBOX @ show a message
\>> IFTE
\>> @ end program
Method 2. INPUT, using some extensions to the built-in command set.
\<<
'IH' VTYPE -1 ==
\<< 0 'IH' STO
\>> IFT
"Enter instr. height"
":IH: " IH + { 0 } +
SINPUT @ SINPUT available in the BROWSE library
\<<
0 isOb @ isOb available in the STRING library
DUP TYPE @ If not a real number
\<<
DROP
"Error: You should enter a real number."
WARNBOX @ WARNBOX is in the BROWSE library
\>> IFT
\>>
\<<
'IH' STO
\>> IFTE
\>>
The nice thing with SINPUT above is that it returns a flag
indicating whether the user canceled the operation, instead of just
aborting as the regular INPUT command. isOb takes a string in level 2,
and an object type number (as per the TYPE command) in level one and
tries to convert the string to an object of the specified type, it
returns a new object on success, or the original string on failure.
Regards,
Diego Berge.