HP Forums

Full Version: HP Prime Programming Tutorial #3: WHILE, INPUT, KILL, REPEAT, GETKEY
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Nice post, Eddie. If I may add some notes:

It is possible to use INPUT(…) as follows:

IF INPUT(…) THEN // note the lack of ; after the closing )
...
ELSE
...
END;

Also, INPUT can also be given a default value (or list of default values).

INPUT(myvar, "Title", "Prompt", "Help Text", default)

When the user uses "Edit" or begins to type their input, they would see the default value appear in the command line. INPUT(…) returns 0 if [On] or [Esc] was pressed and 1 otherwise.

Lastly, inputs are not limited to real numbers. However, the input "type" must be set prior to the INPUT(…) command by setting (in this example) myvar to a dummy value of the desired type. For example, if you want a string, then do:

myvar:="";

prior to using the INPUT. Otherwise, you will only be allowed to enter real values for myvar.

hello,


you can also use INPUT for multiple variables at once:
input({list of vars}, title, {"list of proimpts"} .... )

you also talk about key gathering. You could mention the WAIT(0) command. use it on the command line to quickly get a key number. and use it in program rather than a while getkey in order to limit power use.

Cyrille

Quote:
Nice post, Eddie. If I may add some notes:

It is possible to use INPUT(…) as follows:

IF INPUT(…) THEN // note the lack of ; after the closing )
...
ELSE
...
END;

Also, INPUT can also be given a default value (or list of default values).

INPUT(myvar, "Title", "Prompt", "Help Text", default)

When the user uses "Edit" or begins to type their input, they would see the default value appear in the command line. INPUT(…) returns 0 if [On] or [Esc] was pressed and 1 otherwise.

Lastly, inputs are not limited to real numbers. However, the input "type" must be set prior to the INPUT(…) command by setting (in this example) myvar to a dummy value of the desired type. For example, if you want a string, then do:

myvar:="";

prior to using the INPUT. Otherwise, you will only be allowed to enter real values for myvar.


I think so, I will have to try it.

Update at 5:50 PM PST: Yes. Using INPUT in this way works. Thanks, Han.

Edited: 6 Nov 2013, 8:51 p.m.

Han and Cyrille. Do you mind If I mention your tips on my blog? Credit will be given. Eddie

Hi Eddie,

Please feel free!