This instruction isn't intended to be a primary location of learning to program the HP Prime. These are a few things I've spent hours learning and just want to share so another novice programmer can get up and running faster. The 600+ page manual offered by HP does a good job clarifying syntax and how to get started in programming.
For now, I'm just covering how to display program results.
Step 1: Displaying Results
Depending on what you want to display, there are several options.
- Display a single number (47)
- Display a single number and text (A=47)
- Display multiple numbers (47, 13)
- Display multiple numbers and text (A=47 and B=13)
And another influence is do you want to do more calculations with them?
Once you add text to your program results, you are no longer allowed to do calculations. I prefer not using text because I can't do further calculations with the result (unless I type it on the home screen myself).
When trying to display two or more numbers in a result and still do calculations, I use a matrix or a list.
Here are various syntax examples, (let A and B represent program variables and A=47 and B = 13)
Step 2: Displaying: Example 1
// This will return a value to the home screen, which can be used in future calculations
Step 3: Displaying: Example 2
RETURN "The answer is "+A;
// this returns a string, no further calculations can be done with result, only viewing.
Step 4: Displaying: Example 3
RETURN "A value is " + A + " B value is" + B;
// displays a string, only viewing is allowed, no further calculations can be done.
Step 5: Displaying: Example 4
M1(1) refers to matrix one and the first element in the matrix.
M1(2) refers to matrix one and the second element in the matrix.
Matrixs allow the display of multiple numbers from a program's results as well as allowing you to do further as seen in the pic.
In order to use a matrix, you must go to the matrix list on the HP Prime, and select M1(our matrix of choice), then choose it to be a vector.
For more information on Matrixs, refer to the HP User Guide
Step 6: Displaying: Example 5
L1(1) refers to List 1 and it's first element.
L1(2) refers to List 1 and it's second element.
Lists allow the display of multiple numbers from a program's results as well as allowing you to do further as seen in the pic.
For more information on Lists, refer to the HP User Guide
Step 7: Displaying Numbers in Decimal Form
To get you program to return decimal values, use
the approx will approximate the variable A giving you a decimal answer.
Or, you can run the program from the CAS home, then press the button left of the delete button.