HP Prime Programming Tutorial #3: WHILE, INPUT, KILL, REPEAT, GETKEY



Post: #7

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.


Post: #8

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.


Post: #9

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

Post: #10

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.


Post: #11

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


Post: #12

Hi Eddie,

Please feel free!


Forum Jump: