Post Reply 
Newbie to HP PPL
09-01-2023, 05:34 AM
Post: #1
Newbie to HP PPL
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.
Find all posts by this user
Quote this message in a reply
09-01-2023, 12:54 PM (This post was last modified: 09-02-2023 02:43 PM by Insoft.)
Post: #2
RE: Newbie to HP PPL
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.
Find all posts by this user
Quote this message in a reply
09-01-2023, 01:50 PM (This post was last modified: 09-01-2023 01:52 PM by gehakte_bits.)
Post: #3
RE: Newbie to HP PPL
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]
Find all posts by this user
Quote this message in a reply
09-01-2023, 02:41 PM
Post: #4
RE: Newbie to HP PPL
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
Find all posts by this user
Quote this message in a reply
09-01-2023, 02:47 PM
Post: #5
RE: Newbie to HP PPL
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]
Find all posts by this user
Quote this message in a reply
09-02-2023, 04:32 AM
Post: #6
RE: Newbie to HP PPL
Thanks to all! Code is up and running. I will definately, learn some Python.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)