Post Reply 
Sharing Variables between Python and HPppl
05-19-2022, 07:40 PM (This post was last modified: 05-19-2022 07:44 PM by Guenter Schink.)
Post: #9
RE: Sharing Variables between Python and HPppl
Synchronizing vars in PYTHON and HOME

This can be done by using AVars. Create this PPL Program
Code:
EXPORT test(arg1)
BEGIN
arg1:=arg1+" this is the argument with addition by the PPL";
AVars("arg2"):=AVars("arg2")+" this is the AVars arg2 with addition by PPL";
RETURN {arg1,arg2};
END;
and then this PYTHON program
Code:
from hpprime import *
arg1="arg1 text"
arg2="arg2 text"
eval('AVars("arg2"):='+'"'+arg2+'"')
ttt=eval('test('+'"'+arg1+'"'+')')
eval('PRINT')
print(ttt[0],"\n",ttt[1])
like in the previous post the PYTHON program calls the PPL program with an argument. In addition to that it puts a value into AVars <arg2>. the PPL program does something with the given argument <arg1> and with the AVars<arg2> then it returns the results as a list to the PYTHON program where it may be processed further. In this program the two elements of the list are printed.

Günter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Sharing Variables between Python and HPppl - Guenter Schink - 05-19-2022 07:40 PM



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