Post Reply 
example python ppl with subroutines hp prime
06-08-2021, 01:53 AM (This post was last modified: 06-08-2021 02:42 AM by Liamtoh Resu.)
Post: #1
example python ppl with subroutines hp prime
The following demonstrate the useage of subroutines in python and ppl.
A simple pi approximation was used.

edit: fixed ppl code, was missing predeclaration for cls().

python:
Code:

#PYTHON name
# aprxpi02
import math

def pintro():
  print ("aprxpi02 pi approximation")
  return

def api():
  return 355/113

def pout():
  q1 = api()
  print ("pi = ", q1)

pintro()
pout()

#end 
 
EXPORT aprxpi02()
BEGIN
  PRINT;
  PYTHON(name);
END;

ppl
Code:

// aprxpi01
// predeclare subroutines
cls();
pintro();
api();
pout();

// main program
EXPORT aprxpi01()
BEGIN
cls();
pintro();
pout();
end;

// clear screen
cls()
begin
print();
end;

// print intro
pintro()
begin
print("aprxpi01: pi approximation");
end;

// pi approximation
api()
begin
return 355/113;
end;

// print output
local q1;
pout()
begin
q1 := api();
print("pi = " + q1);
end;

// end of source code

This is for those who are looking for a starting point.

Thanks/
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
example python ppl with subroutines hp prime - Liamtoh Resu - 06-08-2021 01:53 AM



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