Simple scripting question

Posted on
Wed Oct 12, 2016 10:56 am
trevorsmith offline
Posts: 86
Joined: Oct 08, 2016

Simple scripting question

During a scheduled evetn I am calling a script in an external file. This works fine, but in that file I wish to execute a script in another external file (in the same folder as the original), so this (in principle) is what I wish to do

file1.py:

#set a variable or some other python code
indigo.variables[blah blah].....

#now call another script in file2.py
execfile("file2.py")

file2.py:
#do whatever is required!.....


How do I make it work? I get an error stating file2.py doesnt exist

Posted on
Wed Oct 12, 2016 11:13 am
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Simple scripting question

Can you provide a little bit more information on what you want to accomplish? For example, are you passing information from script 1 to script 2? Does script 2 need to wait for script 1 to finish before executing?

The solution may be simpler than you think.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Oct 12, 2016 11:18 am
trevorsmith offline
Posts: 86
Joined: Oct 08, 2016

Re: Simple scripting question

Thanks. I basically wish to use some code in file2 within file1, so file2 should execute then file1 should continue. Basically calling a function within file2

Posted on
Wed Oct 12, 2016 11:30 am
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Simple scripting question

Put the code in file2.py into a function, then import that function in file1 and use it:

Code: Select all
from file2 import myFunction

#set a variable or some other python code
indigo.variables[blah blah].....

myFunction(params)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Oct 12, 2016 12:23 pm
trevorsmith offline
Posts: 86
Joined: Oct 08, 2016

Re: Simple scripting question

thank you

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 6 guests