Login | Register 
FEATURES
APPLICATIONS
DOWNLOADS
EDUCATION
BLOG
WIKI
FORUM
STORE

Calling a function from another op

Still a little green? Ask your beginner's questions here

Calling a function from another op

Postby jpkelly » Mon Jul 09, 2018 4:20 pm

I have a python function in a Text DAT that I would like to reuse in other ops (such as a TCP/IP callbacks Text DAT).
How can I call that function from within another DAT?
jpkelly
 
Posts: 4
Joined: Sat Sep 24, 2016 12:45 am

Re: Calling a function from another op

Postby raganmd » Mon Jul 09, 2018 5:11 pm

Do you want to run the whole DAT or just a specific generalized function in that DAT?

You can use the run() method to run a script in a DAT like this:
base_run_a_dat.tox
(390 Bytes) Downloaded 29 times


You can treat a text DAT as a module with functions like this:
base_dat_as_module.tox
(406 Bytes) Downloaded 29 times


You can also add python extensions as another approach to this challenge. It really comes down to what you're looking to do.

You could read more about python modules in touch here:
https://matthewragan.com/2016/07/12/pyt ... hdesigner/

and extensions here:
https://matthewragan.com/2016/07/14/pyt ... hdesigner/

Does that help you get started?
raganmd
 
Posts: 1350
Joined: Thu Mar 28, 2013 5:21 am
Location: San Francisco, CA

Re: Calling a function from another op

Postby jpkelly » Tue Jul 10, 2018 1:44 am

Yes, Thank you!
Your base_dat_as_module.tox example worked perfectly for me!
jpkelly
 
Posts: 4
Joined: Sat Sep 24, 2016 12:45 am


Return to Beginners

Who is online

Users browsing this forum: No registered users and 14 guests