06-08-2021, 01:53 AM
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:
ppl
This is for those who are looking for a starting point.
Thanks/
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/