Post Reply 
Input a default value
03-17-2015, 08:08 PM
Post: #1
Input a default value
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

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
03-17-2015, 08:28 PM
Post: #2
RE: Input a default value
(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.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
03-17-2015, 08:42 PM
Post: #3
RE: Input a default value
(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?

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
03-18-2015, 06:55 AM
Post: #4
RE: Input a default value
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
Find all posts by this user
Quote this message in a reply
03-18-2015, 08:37 AM
Post: #5
RE: Input a default value
(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?

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
03-18-2015, 02:51 PM
Post: #6
RE: Input a default value
(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.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
03-18-2015, 02:54 PM
Post: #7
RE: Input a default value
(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

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
03-18-2015, 05:28 PM
Post: #8
RE: Input a default value
I now know what is the reset value
thank you
Find all posts by this user
Quote this message in a reply
03-19-2015, 06:49 PM
Post: #9
RE: Input a default value
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...

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
03-19-2015, 08:29 PM
Post: #10
RE: Input a default 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);
Find all posts by this user
Quote this message in a reply
03-19-2015, 08:38 PM (This post was last modified: 03-19-2015 08:59 PM by salvomic.)
Post: #11
RE: Input a default value
(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?

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
03-19-2015, 08:45 PM
Post: #12
RE: Input a default value
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...

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)