• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

scheduleTask() doesn't work !

Community Beginner ,
Oct 24, 2012 Oct 24, 2012

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!!!!!

TOPICS
Scripting

Views

1.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 24, 2012 Oct 24, 2012

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 25, 2012 Oct 25, 2012

Copy link to clipboard

Copied

On Aeenhancers I've seen it's better to:

var theStr = "the javascript code etc";

scheduleTask(theStr,1000,false);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 25, 2012 Oct 25, 2012

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();}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 26, 2012 Oct 26, 2012

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 26, 2012 Oct 26, 2012

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 01, 2012 Nov 01, 2012

Copy link to clipboard

Copied

I found out that if scheduleTask() doesn't work, you can use

$.sleep(1000);

eval(string);

instead.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 02, 2012 Nov 02, 2012

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 22, 2016 Mar 22, 2016

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines