Friday, May 30, 2014

HP Prime: Ways to use the INPUT command (Version 6030)

Note: This is for HP Prime Software Version 6030 (2014 3 31)


The INPUT Command

On the HP Prime, the INPUT command can include various types of input forms: numeric fields, choose boxes, and check boxes. You can also restrict which types of input are accepted. This blog entry will cover some of the basic forms of INPUT. 

For a video on the subject, click here:  https://www.youtube.com/watch?v=qSY6RXvAHuw

Basic Form

INPUT(var, title, label);

var = can be one or a list
title = optional string
label = optional string, number of labels are equal to number of var

The example programs presented (except for IN4) win use one variable.

Here is an example of the basic format. Keep in mind, the title and label strings are optional.


EXPORT IN1( )
BEGIN
// Basic
INPUT(X, "Enter X");
RETURN √(1+X^2);
END;


Specifying Types

INPUT( {var, [types allowed]}, title, label);

Type numbers are surrounded in square brackets.

Common Types:
-1 All
0 real numbers
1 integers
2 strings
3 complex numbers
4 matrices
6 lists
8 functions
9 numbers with units
14.? CAS objects

IN2 and IN3 are programs that ask for a specific type. IN2 asks for a matrix (type 4) and IN3 asks for a list (type 6).


EXPORT IN2( )
BEGIN
// Ask for a Matrix
INPUT({{M0,[4]}}, "Matrix");
RETURN M0*TRN(M0);
END;



EXPORT IN3( )
BEGIN
// Ask for a List
INPUT({{L0, [6]}}, "List");
PRINT( );
PRINT("Σx ="+STRING(ΣLIST(L0)));
PRINT("mean = "+STRING(approx(mean(L0))));
PRINT("std dev ="+STRING(approx(steddevp(L0))));
END;


Checkboxes

INPUT({{var, n}}, title, label);

n groups the current and next n-1 checkboxes. If you want a checkbox next to each variable, let n = 1. A variable that is checked has a value of 1. Otherwise, the value is 0. Each variable and it's corresponding n are surrounded in curly brackets.


EXPORT IN4( )
BEGIN
// Checkboxes
INPUT( {{A,1}, {B,1}, {C,1}}, "Turn On Variables");
PRINT( );
PRINT("Number of Checks: "+STRING(A+B+C));
END;


If you want to use more than one input form, I advise to keep INPUT types separate.


EXPORT IN5( )
BEGIN
// Checkbox Modes
INPUT( {{M,1}}, "Check for Degrees");
HAngle:=M;
// Input Data
INPUT(A, "Angle");
PRINT( );
PRINT("SIN(2A)² =");
PRINT(SIN(2*A)²);
END;


Choose Boxes

This INPUT form will create a choose box (drop down list).

INPUT( {{ var, {choice0, choice1, choice2...} }}, title, label)

Follow this by:

IF var == 0 THEN choice0 instructions...(END;)
ELSE (if there are only two choices) or
IF var ==1 THEN choice1 instructions... END; and so on...


EXPORT IN6( )
BEGIN
INPUT( {{C, {"SI","US"} }}, "Units of g");
IF C==0 THEN
RETURN "g = 9.80665 m/s^2"; KILL;
ELSE
RETURN "g = 32.17404 ft/s^2"; END;
END;


That is some of the ways we can use the INPUT command on the HP Prime. To check out all of the ways INPUT command, including putting the prompts in specific places, check out the help screen for INPUT.

Eddie

This blog is property of Edward Shore. 2014