Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
In short no… You need to work with V1.4 ( eek I think? )
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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");
Copy link to clipboard
Copied
$.sleep(3000);
I hope It will not make indesign Idle. Some body please raise the confirmation...
Green4ever
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
What's wrong with the idle task?
Long back I tried to adjust the width of tables and colums, after adjusting the width i have to recompose the table every time to get the adjusted value, I tried using $.sleep() here but it didn't worked that way.
You can question me why you used $.sleep()? when script stops running it automatically recomposes the table to its adjusted width. So I tried in that way, after that I go with recompose() method.
Green4ever
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more