HP Forums
Input a default value - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Input a default value (/thread-3408.html)



Input a default value - salvomic - 03-17-2015 08:08 PM

hi all,
for the INPUT command, is there an option to give a default value?
For example:
INPUT(val1, "A value", "give val", "give the value if not 5");
the user should give a value, but if he/she doesn't I would like the value should be 5 by default...

TIA

Salvo


RE: Input a default value - Han - 03-17-2015 08:28 PM

(03-17-2015 08:08 PM)salvomic Wrote:  hi all,
for the INPUT command, is there an option to give a default value?
For example:
INPUT(val1, "A value", "give val", "give the value if not 5");
the user should give a value, but if he/she doesn't I would like the value should be 5 by default...

TIA

Salvo

Yes, it's explained in the help screen. Type INPUT on the command line and hit the help key.


RE: Input a default value - salvomic - 03-17-2015 08:42 PM

(03-17-2015 08:28 PM)Han Wrote:  Yes, it's explained in the help screen. Type INPUT on the command line and hit the help key.

thank you!
I see, now it's more clear...
So, if I use:
INPUT(val1, "A value", "give val", "give the value if not 5", 1, 5);
it should be 5 with "OK" and 1 with "Cancel", isn't it?


RE: Input a default value - cyrille de brébisson - 03-18-2015 06:55 AM

Hello,

If cancel, the value in the variable will stay unchanged.

They are 3 values associated with each variables:
1) The current value in the variable (unchanged if CANCEL pressed)
2) The Value which is proposed to the user when the INPUT comes up
3) The value which will be proposed to the user if the user presses CLEAR

If the user presses OK, then whatever the value currently displayed will be used.
If the user pressed CANCEL, the value of the variable will stay unchanged.

Cyrille


RE: Input a default value - salvomic - 03-18-2015 08:37 AM

(03-18-2015 06:55 AM)cyrille de brĂ©bisson Wrote:  If the user presses OK, then whatever the value currently displayed will be used.
If the user pressed CANCEL, the value of the variable will stay unchanged.

Cyrille

thank you, Cyrille,
but so, the "Clear" value, when is used?


RE: Input a default value - Tim Wessman - 03-18-2015 02:51 PM

(03-18-2015 08:37 AM)salvomic Wrote:  but so, the "Clear" value, when is used?

When you press CLEAR or BKSP in the form. Doing it this way means you can have a separate "reset" value, and a "current" value on initial entry.


RE: Input a default value - salvomic - 03-18-2015 02:54 PM

(03-18-2015 02:51 PM)Tim Wessman Wrote:  When you press CLEAR or BKSP in the form. Doing it this way means you can have a separate "reset" value, and a "current" value on initial entry.

Thank you, Tim.
It can be useful in some cases.
I'll do some tries.

Salvo


RE: Input a default value - Tyann - 03-18-2015 05:28 PM

I now know what is the reset value
thank you


RE: Input a default value - salvomic - 03-19-2015 06:49 PM

How recall INPUT() if there is an error?
I mean, I have this
Code:

...
INPUT(aleph, "Title", "input aleph value", "Aleph is a bogus var", 0, 3);
IF (aleph < 1) THEN ... // there is an error but please don't exit...
...

if aleph value is <1 I don't want the program exit but that it recall INPUT() again to correct value...


RE: Input a default value - Didier Lachieze - 03-19-2015 08:29 PM

(03-19-2015 06:49 PM)salvomic Wrote:  if aleph value is <1 I don't want the program exit but that it recall INPUT() again to correct value...

What about something like:
Code:
REPEAT
  INPUT... 
UNTIL (aleph >= 1);



RE: Input a default value - salvomic - 03-19-2015 08:38 PM

(03-19-2015 08:29 PM)Didier Lachieze Wrote:  What about something like:
Code:
REPEAT
  INPUT... 
UNTIL (aleph >= 1);

thank you Didier!
In fact I thing to do so (also with CASE and some IF's):
Code:

control:=1;
REPEAT
INPUT ...;  // aleph and a few others vars
CASE
IF (aleph<1) THEN ...; control:=1; END;
IF ... THEN ...; control:=1; END;
IF ...
DEFAULT control:=0; END;
END; // case
UNTIL control <1;
...

it works!

However there is a problem: if the "IF control" repeats the cycle, the value of every variables will be reset: there is a way to maintain the right ones when the input is newly showed?


RE: Input a default value - salvomic - 03-19-2015 08:45 PM

Another question about INPUT:
is is possible to customize OK in the menubar, like "Calc" in Statistics?

More precisely, I'd like this:
having a multiline input, when every lines are set, change the OK into "Calc" and calculate with the values...