Copy link to clipboard
Copied
Hi guys,
I was tring to write a function that can repeatly run itself once per second,and I used app.scheduleTask().
like this,
function newFunction () {
......
......
scheduleTask("newFunction ()",1000,false);
}
Sometimes it worked, sometimes it didn't work.
Is there something about scheduleTask() that I don't know ?
Or, could you guys tell me how to write a function that can diaplay a number that increase 1 per second on a scriptUI panel ?
Thank you!!!!!
Copy link to clipboard
Copied
not sure if this is it, but the dosc say to give the scheduleTask() function a string of javascript, where you are supplying a function (which seems like the better way but maybe thats the problem).
Mike Cardeiro
Editor/Animator/Compositor
D4 Creative Group - Philadelphia, PA
http://www.michaelcardeiro.com/resume/
http://www.youtube.com/user/mcardeiro
Copy link to clipboard
Copied
On Aeenhancers I've seen it's better to:
var theStr = "the javascript code etc";
scheduleTask(theStr,1000,false);
Copy link to clipboard
Copied
Make sure the code your are feeding in the scheduletask is perfectly written. No syntax error, semi-colon at the end of every line of code.
Think of it as if there is no carriage return in you code, it still should execute.
function notWorking(){
var a = "test"
var b = anotherFunction()
}
will give :
function notWorking(){var a = "test"var b=anotherFunction()}
SO PUT SEMICOLONS!
function working(){
var a = "test";
var b = anotherFunction();
}
will give :
function working(){var a = "test";var b=anotherFunction();}
Copy link to clipboard
Copied
Seeing we are on this-
I was wondering if there was a more elegant way of: 'Checking to see if the user has changed the open project'.
Currently the only way I think is to schedule a task that checks every 5 seconds. I need it checked automatically, so I don't want to use an update button etc.
Am I stuck with running tasks repeatedly?
Copy link to clipboard
Copied
Don't go that route, a scheduled task running in background will just break whenever you open a window - e.g. Composition settings.
Copy link to clipboard
Copied
I found out that if scheduleTask() doesn't work, you can use
$.sleep(1000);
eval(string);
instead.
Copy link to clipboard
Copied
Thanks a lot - will try out and see how it affects general workflow in AFX.
Have ye noticed a background thread running like this causes havoc with working away in AFX? Don't want to get into it if it's problematic.
I am using an 'update' button at the moment - but it would be nice if the script could pick up the changes automatically.
Cheers.
Copy link to clipboard
Copied
Know this is quite an old thread but came back to this and not having any issues using scheduleTask....
The most important thing is that it is a string and not code, so that it responds to the "eval" that Adobe calls each iteration.
The modal dialogs seem to pause the running but then it resumes when a dialog closes, that makes sense.
I came across some code behind the ESTK that uses the scheduleTask in quite an advanced way... an ESTK version but
same principals apply - probably quite similar.