Equation library program analyzed

Publicado el por

Equation library program analyzed

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:

EXPORT eqnlib()

BEGIN

// March-April 2015 EWS

// Equation Library Similar to HP 48 series

// Variables A-Z & θ are global

// Initialization

LOCAL ch,d;

STARTAPP(“Solve”);

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

// Choose

// Main Menu

CHOOSE(ch,”Equation Library”,

{“Geometry”,”Finance”,”Temperature”,

“Physics-Motion”,

“Sound”,”Optics”,

“Electronics”,”Astronomy”,

“Great Circle”,

“Angle of Incidence”,

“Gases”,”Fluids”});

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

CHOOSE(d,”Geometry”,{“Area: Circle”,

“Area: Ellipse”,

“Area: Trapezoid”,

“Volume: Sphere”,

“Volume: Cylinder”,

“Volume: Cone”,

“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

“A=π*R2”▶E1;

PRINT();

PRINT(“A = Area”);

PRINT(“R = Radius”);

END;

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

“A=NS2/4COT(180°/N)”▶E1;

PRINT();

PRINT(“A = Area”);

PRINT(“N = Number of Sides”);

PRINT(“S = Length of a Side”);

END;

// Close out Geometry Loop

END;

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);

STARTVIEW(2,1);

END;

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)

Startview(2,1):

STARTVIEW(ViewNumber[,Redraw])

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:

0=Symbolic

1=Plot

2=Numeric

3=Symbolic Setup

4=Plot Setup

5=Numeric Setup

6=App Info

7=Views key

 

Did you learn anything? I did.

Comentarios: 0
Más sobre: HP prime, equation library

Solo los usuarios registrados pueden poner comentarios.
Identificarse y añadir comentario Regístrese ahora