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

setTimeout() method

Mentor ,
Feb 10, 2012 Feb 10, 2012

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

TOPICS
Scripting
4.1K
Translate
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
Mentor ,
Feb 10, 2012 Feb 10, 2012

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

Translate
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
LEGEND ,
Feb 11, 2012 Feb 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.

Translate
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
Explorer ,
May 09, 2012 May 09, 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");

Translate
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 ,
May 09, 2012 May 09, 2012

$.sleep(3000);

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

Green4ever

Translate
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
LEGEND ,
May 09, 2012 May 09, 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.

Translate
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 ,
May 09, 2012 May 09, 2012
LATEST

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

Translate
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