|My first HP Prime PPL Program|
Message #1 Posted by Michael de Estrada on 18 Oct 2013, 10:37 a.m.
This is my first ever non RPL program and it took me several hours to figure it out and get it to work, since I'm totally unfamiliar with the language, syntax, conventions and interface. Also, many needed commands are not included or explained in the calculator commands list. For example, I was unable to get the program to run w/o crashing and resetting the calculator until I inserted the LOCAL statement. In other cases I received a syntax error doing a Check of the code when using the exact syntax shown in an example in the User Guide. During the development I encountered numerous sudden resets of the calculator while entering/editing the program, which seems to be commonplace with this calculator. Fortunately, however, I did not corrupt the flash drive this time around.
This program performs 2D polar<>rectangular coordinate conversions, which are not supplied as built-in functions on the Prime. Note that I have substituted "Theta" and "SQRT" in this posting in place of the actual symbols, since they would not display properly.
IF N=1 THEN
INPUT(X1,"To Polar","X =","Enter X",1);
INPUT(X2,"To Polar","Y =","Enter Y",1);
PRINT("R = " +SQRT(X1²+X2²) );
PRINT("Theta = " +ATAN(X2/X1) );
IF N=2 THEN
INPUT(X1,"To Rectangular","R =","Enter R",1);
INPUT(X2,"To Rectangular","Theta =","Enter Theta",1);
PRINT("X = " +X1*COS(X2) );
PRINT("Y = " +X1*SIN(X2) );