The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

HP Prime Programming Tutorial #3: WHILE, INPUT, KILL, REPEAT, GETKEY
Message #1 Posted by Eddie W. Shore on 5 Nov 2013, 10:07 p.m.

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
Message #2 Posted by Han on 6 Nov 2013, 12:00 a.m.,
in response to message #1 by Eddie W. Shore

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
Message #3 Posted by cyrille de Brébisson on 6 Nov 2013, 1:45 a.m.,
in response to message #2 by Han

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
Message #4 Posted by Eddie W. Shore on 6 Nov 2013, 8:29 p.m.,
in response to message #2 by Han

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
Message #5 Posted by Eddie W. Shore on 6 Nov 2013, 8:52 p.m.,
in response to message #4 by Eddie W. Shore

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
Message #6 Posted by Han on 7 Nov 2013, 12:25 a.m.,
in response to message #5 by Eddie W. Shore

Hi Eddie,

Please feel free!


[ Return to Index | Top of Index ]

Go back to the main exhibit hall