The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Access "python funtion" in column via Labtalk?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Leif12

Germany
13 Posts

Posted - 05/22/2022 :  1:11:14 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Dear Origin Forum,

is there a way to access the python function field in a column via the Labtalk Script window?
I know I can access the column values and the before formula script with
csetvalue formula:="..." col:=1 script:="..."
but how do I access the python function field?

Best regards,
Leif Schwensow

cpyang

USA
1406 Posts

Posted - 05/23/2022 :  12:42:23 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can access by wks.col.py$, for example if you have Python function defined for column B, then

wks.col2.py$=;


BTW, you can access Fx and before script by

wks.col2.Formula$
wks.col2.Script$

CP
Go to Top of Page

Leif12

Germany
13 Posts

Posted - 05/28/2022 :  04:32:25 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks CP, that was exactly what I was looking for.

However, I still have the issue that I always get an error after running the Labtalk script
wks.col1.Script$="...";
wks.col1.py$="...";
since the python function needs the before fomula script and the before formula script needs the python function (so I couldn't just switch the order).
(ERR0015105: Python function cannot be found.)

Only after running the second step (wks.col1.py$="...";) again and separately after the error message leads to the correct calculation.

Is there a way to supress the calculation until both scripts are entered?

Best regards
Leif
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 05/28/2022 :  8:17:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Yes, I can see the problem. I added ORG-25299 and we will fix for the next version. Do you have your LT code in an ogs file? The simplest fix is to detect LT code is executed in a file, instead of Script Window or Command Window and the wks.col.py$ line will not execute internal recalculation.

There is a simple workaround though, which you had implied, basically the Recalculate Operation needs to be setup successfully first, then changing in the proper order will work, see

wks.col2.script$="i=1;";//something to setup the operation
wks.col2.py$=
"def add1(a):
    return [val+1 for val in a], [val+2 for val in a]
";
wks.col2.script$="col(B),col(C)=py.add1(col(A))";



CP
Go to Top of Page

Leif12

Germany
13 Posts

Posted - 06/03/2022 :  07:29:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks, that works.
Best
Leif
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000