HP Forums
HP Prime Programming Tutorial #3: WHILE, INPUT, KILL, REPEAT, GETKEY - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: HP Prime Programming Tutorial #3: WHILE, INPUT, KILL, REPEAT, GETKEY (/thread-254971.html)



HP Prime Programming Tutorial #3: WHILE, INPUT, KILL, REPEAT, GETKEY - Eddie W. Shore - 11-05-2013

http://edspi31415.blogspot.com/2013/11/hp-prime-programming-tutorial-3-while.html

And a tip from Miguel Toro: (Thanks Miguel!)

http://edspi31415.blogspot.com/2013/11/hp-prime-tip-rpn-and-created-programs.html


Edited: 5 Nov 2013, 10:08 p.m.


Re: HP Prime Programming Tutorial #3: WHILE, INPUT, KILL, REPEAT, GETKEY - Han - 11-06-2013

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.


Re: HP Prime Programming Tutorial #3: WHILE, INPUT, KILL, REPEAT, GETKEY - cyrille de Brébisson - 11-06-2013

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


Re: HP Prime Programming Tutorial #3: WHILE, INPUT, KILL, REPEAT, GETKEY - Eddie W. Shore - 11-06-2013

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.


Re: HP Prime Programming Tutorial #3: WHILE, INPUT, KILL, REPEAT, GETKEY - Eddie W. Shore - 11-06-2013

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


Re: HP Prime Programming Tutorial #3: WHILE, INPUT, KILL, REPEAT, GETKEY - Han - 11-07-2013

Hi Eddie,

Please feel free!