Skip to main content
Jump_Over
Brainiac
February 10, 2012
Question

setTimeout() method

  • February 10, 2012
  • 3 replies
  • 4029 views

Hello,

Thats a beginner question:

Is there setTimeout() & clearTimeout() javascript methods possible to use inside .jsx script with InDesign #targetengine "session"?

I would like to start Indesign action if modification date of my specified .txt file is changed.

For example in this way:

1. Create window ("palette") with buttons "Start" and "Stop" with .onClick functions to setTimeout(myFunction(), interval) and clearTimeout();

2. myFunction will check file.modified property and compare it with last changed;

3. myScript will start if myFunction() say true;

I found an example how to use this methods here: http://www.w3schools.com/js/js_timing.asp

But that is all about inside http body. Has someone experience with this writing Indesign actions script?

Or is it useless here?

thx

This topic has been closed for replies.

3 replies

thinkink_es1
Inspiring
May 9, 2012

You can use:

The $ object provides a number of debugging facilities and informational methods.

more info in:

http://jongware.mit.edu/idcs5/pc_$.html

example:

alert("hello");

$.sleep(3000);

alert("bye bye");

Green4ever
Inspiring
May 9, 2012

$.sleep(3000);

I hope It will not make indesign Idle. Some body please raise the confirmation...

Green4ever

John Hawkinson
Inspiring
May 9, 2012

The $.sleep() method certainly causes your JavaScript to block.

That makes it unsuitable most of the time.

What's wrong with the idle task?

You can also shell out to the operating system (VB or AppleScript) and launch a background process.

John Hawkinson
Inspiring
February 11, 2012

This is not a JavaScript 1.4 issue, it is rather that setTimeout() is not part of Javascript, it is part of a web browser's DOM.

You can achieve similar results in InDesign (CS5 or later only) by creating an app.idleTask with an appropriate sleep parameter, and then adding an event listenre to the task for the IdleEvent.ON_IDLE event.

I would encourage you to ignore w3schools.com, it has a lot of bad information. See http://w3fools.com/ for some explanations why.

Inspiring
February 10, 2012

In short no… You need to work with V1.4 ( eek I think? )