Post Reply 
Passing values from PPL to Python and vice versa - an alternative to AVars
12-05-2023, 10:35 PM
Post: #4
RE: Passing values from PPL to Python and vice versa - an alternative to AVars
Quote:Of course, it returns a list. Just set HSeparator to any of these values: 0, 1, 2, 3, 9, 10. You will see that the program will work exactly as I provided in the example and return a list (or more precisely, a vector). This works for both EXPORT and LOCAL (declared outside of any function) variables.
Regarding the "PYPPL" prefix (the program name), it allows you to refer to local variables and call local PPL functions. Without this prefix, you can only refer to EXPORT variables and functions.
See the Example 4 => the PPL_SUBROUTINE() is a local function.

Sorry Piotr, I believe it doesn't. To verify this, you first have to delete the user variable "pyresult" because it certainly contains what's left over from the various checks you already have done.
In Home call the Vars Menu, select "User", "User Variables" and delete what's in there. Then run this program again.

Alternatively change "numbers= range(10)" to "numbers = range(7)" and check the result.
In addition I think it's always wise to check the result of an hpprime.eval() statement. I.e change the line:
"ppleval('PYPPL.pyresult:=%s' %numbers);"
to:
"check=ppleval('PYPPL.pyresult:=%s' %numbers); "
and have a look what a consecutive line:
"print(check)" produces. It simply shows you that you have produced "Error: Syntax Error" in the Home environment.

A minor thing: It's superfluous to end a Python line with ";"

The fact that you always see the seemingly correct result is owed to the the variable "pyresult" never being changed during your various tests.

I didn't have a closer look to sample #4, but "print(nxn)" after "nxn= ppleval(...)" also reveals that PPL environment is not happy

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


Messages In This Thread
RE: Passing values from PPL to Python and vice versa - an alternative to AVars - Guenter Schink - 12-05-2023 10:35 PM



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