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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Access "python funtion" in column via Labtalk?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Leif12 Posted - 05/22/2022 : 1:11:14 PM
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
4   L A T E S T    R E P L I E S    (Newest First)
Leif12 Posted - 06/03/2022 : 07:29:36 AM
Thanks, that works.
Best
Leif
cpyang Posted - 05/28/2022 : 8:17:35 PM
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
Leif12 Posted - 05/28/2022 : 04:32:25 AM
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
cpyang Posted - 05/23/2022 : 12:42:23 PM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000