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

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.

#2

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.

#3

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

#4

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.

#5

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

#6

Hi Eddie,

Please feel free!



Possibly Related Threads…
Thread Author Replies Views Last Post
  HP Prime Tutorial #6 and #7: Drawing Eddie W. Shore 2 1,864 12-10-2013, 08:16 AM
Last Post: Eddie W. Shore
  Programming workaround for "prepend" HP PRIME Marek Russ 4 1,983 11-29-2013, 05:46 AM
Last Post: Marek Russ
  getkey() Tony Gallo 3 1,628 11-23-2013, 10:51 PM
Last Post: Tony Gallo
  INPUT for HP Prime Eddie W. Shore 3 1,610 11-17-2013, 04:46 PM
Last Post: Michael de Estrada
  HP Prime Tutorial #4 is up (CASE/CHOOSE/INPUT) Eddie W. Shore 1 1,278 11-15-2013, 07:32 AM
Last Post: Davi Ribeiro de Oliveira
  hp prime - programming with lists giancarlo 3 1,845 11-10-2013, 02:13 AM
Last Post: Giancarlo
  HP Prime - programming bluesun08 2 1,434 11-04-2013, 04:31 PM
Last Post: bluesun08
  More undocumented programming limitations in the HP Prime Michael de Estrada 3 1,845 11-03-2013, 08:22 PM
Last Post: Michael de Estrada
  HP Prime questions: I/O and Meta programming Andy Gryc 2 1,478 10-31-2013, 11:22 PM
Last Post: Andy Gryc
  HP Prime Programming Tutorial #1: LOCAL, RETURN Eddie W. Shore 6 2,944 10-26-2013, 08:42 PM
Last Post: Miguel Toro

Forum Jump: