I loaded Eddie Shore’s Equation program in my HP Prime, tested it, and liked it a lot. There are a couple of things that could be improved, but it would require more work. But the program is very simple and good to go through and learn how easy is to achieve things in HP Prime with simple, easy to understand programs.
Let’s go through it together, and learn a couple of things meanwhile:
// March-April 2015 EWS
// Equation Library Similar to HP 48 series
// Variables A-Z & θ are global
(Eddie didn’t use the #pragma instruction since it wasn’t available at the time he wrote the program. I have already had some problems with it due to that - but that’s an easy fix. Just remember to place it at the very beginning of the file.
Then he initializes some local variables, that will be used for the menu choices. After that, he starts the solve app - since you could be anywhere else.)
// Main Menu
“Angle of Incidence”,
IF ch==0 THEN KILL; END;
This instruction creates a menu on the screen, gives it a title, lays down the choices, and stores the choice in the variable ch.
// 1 Geometry Loop
IF ch==1 THEN
“Surface Area: Sphere”,
“Surface Area: Cylinder”,
“Distance of 2 Points”,
“Regular Polygon: Σ Angles”,
“Area: Regular Polygon”});
IF d==0 THEN KILL; END;
Then, choice after choice on menu 1, he does the same thing, but with a level two menu: you choose the equations you will use. Again, the choice is stored in a variable: d in this case. if clicked out of the menu, or escaped, you get zero and you’re out of the program.
// 1.1 Area: Circle
IF d==1 THEN
PRINT(“A = Area”);
PRINT(“R = Radius”);
Choice per choice, he stores the equation in the system variable E1 (which is the first equation in the solver). Then, prints on the screen the variables used. These will disappear when you click any key; and then you’re left with the solver. (Here is one of the improvements that could be done: we could print the formula after the variables used. I’ll do it on Monday night, when I have some time.
// 1.11 Area: Regular Polygon
IF d==11 THEN
PRINT(“A = Area”);
PRINT(“N = Number of Sides”);
PRINT(“S = Length of a Side”);
// Close out Geometry Loop
Let’s not forget this last end, to close the Geometry chapter loop!!
Finalizing, we have these two instructions, to display the solver using the formula we have set in E1:
// Display Solver
Check(1) selects the first formula in the current app, which is the solver. (Check(2) w ould have checked the second, and so on)
Starts a view of the current app. Redraw, is optional; if Redraw, is true (non 0), it will force a refresh for the view.
The view numbers are as follows:
Did you learn anything? I did.