HP Forums

Full Version: Input a default value
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
(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.
(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?
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
(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?
(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.
(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
I now know what is the reset value
thank you
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...
(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);
(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?
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...
Reference URL's