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.
|