HP Forums
Newbie to HP PPL - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Newbie to HP PPL (/thread-20437.html)



Newbie to HP PPL - nonakag - 09-01-2023 05:34 AM

Hi Everyone,

I've taken formal Computer Languages courses, however, finding HP PPL quite difficult to find basic examples on the web. I'm trying to do the following pseudo code below:

Local A, B, C, D;
"Sin Θ = OPP/HYP";
"Enter 0 for Unknown"
"Sin Θ"? -->A;
"OPP"? --> B;
"HYP"?-->C;
If A=0;
Then B/C -->D;
"B/C=" D;
"Θ =" Sin^-1(D) --> E;

Basically, baby steps before I get into Functions with arguments.

Any assistance is greatly appreciated. Thank you.


RE: Newbie to HP PPL - Insoft - 09-01-2023 12:54 PM

You need to look at the tread HP-Prime: Documentation & Tutorials it has links to all stuff relating to what you’re looking for.

Other sites
https://www.hpcalc.org
https://en.hpprime.club
http://www.wiki4hp.com

To do Python within PPL
Code:
#PYTHON name
from hpprime import *
from micropython import *
#your python code here [/quote]
#end

You will want to write in PPL + Python, mainly python.


RE: Newbie to HP PPL - gehakte_bits - 09-01-2023 01:50 PM

Here are some examples in PPL [/code]...
Code:

// 2023.0901 pretty-prime v0.3b
#pragma mode(separator(.,;) integer(h32))

//=============
EXPORT prog()                               // most literally
BEGIN 
LOCAL a,b,c,d,e;
  PRINT();
  PRINT("Enter zero for unknown");WAIT(1);
  PRINT("Sin Θ = OPP/HYP");
  INPUT(a,"Sin Θ");
  INPUT(b,"OPP");
  INPUT(c,"HYP");
  IF a=0 THEN 
    d:=b/c;
    e:=ASIN(d);
    PRINT("B/C = "+d);
    PRINT("Θ ="+e);
  END;
END;

//=============
EXPORT prog1()                              // fancier input
BEGIN 
LOCAL x,a,b,c,d,e;
  x:=INPUT({{a,[0],{30,30,1}},
            {b,[0],{30,30,2}},
            {c,[0],{30,30,3}}},
           "Sin Θ = OPP/HYP",
           {"Sin Θ ","OPP ","HYP "},{},{},{0,10,10});
  IF x=1 THEN 
    d:=b/c;
    e:=ASIN(d);
    PRINT();
    PRINT("B/C = "+d);
    PRINT("Θ ="+e);
  END;
END;

//============= one of many solve solutions...(FNROOT,ROOT,fsolve...) 
EXPORT hypp,opp,sinΘ;                       // must use externals with Solve
EXPORT prog2()                              // use solver
BEGIN 
  E1:='SIN(sinΘ)=opp/hypp';
  FOR X:=0 TO 9 DO 
    Solve.UNCHECK(X);
  END;
  Solve.CHECK(1);                           // select E1
  STARTAPP("Solve");
  STARTVIEW(2);
  DelHVars(sinΘ);
END;
[code]



RE: Newbie to HP PPL - nonakag - 09-01-2023 02:41 PM

INSOFT, Thank you, I'm mostly old school, Basic, Assembly Language, Fortran, C++, Pascal,
and Cobol. I will need to take a Python Class, before trying this. Thank you for your advice and I will definately be trying this in the future.

(09-01-2023 12:54 PM)Insoft Wrote:  You need to look at the tread HP-Prime: Documentation & Tutorials it has links to all stuff relating to what you’re looking for.

Other sites
https://www.hpcalc.org
https://en.hpprime.club

To do Python within PPL
Code:
#PYTHON name
from hpprime import *
from micropython import *
#your python code here [/quote]
#end



RE: Newbie to HP PPL - nonakag - 09-01-2023 02:47 PM

gehakte_bits, Super thank you for the great examples. This will definately get me up and running for my pseudo code.

(09-01-2023 01:50 PM)gehakte_bits Wrote:  Here are some examples in PPL [/code]...
Code:

// 2023.0901 pretty-prime v0.3b
#pragma mode(separator(.,;) integer(h32))

//=============
EXPORT prog()                               // most literally
BEGIN 
LOCAL a,b,c,d,e;
  PRINT();
  PRINT("Enter zero for unknown");WAIT(1);
  PRINT("Sin Θ = OPP/HYP");
  INPUT(a,"Sin Θ");
  INPUT(b,"OPP");
  INPUT(c,"HYP");
  IF a=0 THEN 
    d:=b/c;
    e:=ASIN(d);
    PRINT("B/C = "+d);
    PRINT("Θ ="+e);
  END;
END;

//=============
EXPORT prog1()                              // fancier input
BEGIN 
LOCAL x,a,b,c,d,e;
  x:=INPUT({{a,[0],{30,30,1}},
            {b,[0],{30,30,2}},
            {c,[0],{30,30,3}}},
           "Sin Θ = OPP/HYP",
           {"Sin Θ ","OPP ","HYP "},{},{},{0,10,10});
  IF x=1 THEN 
    d:=b/c;
    e:=ASIN(d);
    PRINT();
    PRINT("B/C = "+d);
    PRINT("Θ ="+e);
  END;
END;

//============= one of many solve solutions...(FNROOT,ROOT,fsolve...) 
EXPORT hypp,opp,sinΘ;                       // must use externals with Solve
EXPORT prog2()                              // use solver
BEGIN 
  E1:='SIN(sinΘ)=opp/hypp';
  FOR X:=0 TO 9 DO 
    Solve.UNCHECK(X);
  END;
  Solve.CHECK(1);                           // select E1
  STARTAPP("Solve");
  STARTVIEW(2);
  DelHVars(sinΘ);
END;
[code]



RE: Newbie to HP PPL - nonakag - 09-02-2023 04:32 AM

Thanks to all! Code is up and running. I will definately, learn some Python.