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

why this scheduleTask not work ?

Community Beginner ,
Aug 10, 2018 Aug 10, 2018

Copy link to clipboard

Copied

function tebb() {

var xx = 0;

var ccr = app.scheduleTask("checkStatus()", 2000, true);

var checkStatus = function () {

if (xx < 5) {

alert(xx);

xx++;

} else {

app.cancelTask(ccr)

}

}

}

tebb()

the above code will not run in AE

but without the function tebb(), it works!

why is happened?

TOPICS
Scripting

Views

494

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
Enthusiast ,
Aug 10, 2018 Aug 10, 2018

Copy link to clipboard

Copied

Because of the variable, that you are using for the task, has to be a global variable.

Put it outside of the function and everything will work.

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 ,
Aug 11, 2018 Aug 11, 2018

Copy link to clipboard

Copied

LATEST
  1. function tebb() { 
  2. var xx = 0
  3. var ccr = app.scheduleTask("checkStatus()", 2000, true); 
  4.  
  5.  
  6. checkStatus = function () { 
  7. if (xx < 5) { 
  8. alert(xx); 
  9. xx++; 
  10. } else
  11. app.cancelTask(ccr) 
  12. tebb()

thanks! make checkStatus be a global and works!

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