Skip to main content
TᴀW
Legend
June 2, 2009
Question

Question regarding doScript (InDesign CS4)

  • June 2, 2009
  • 2 replies
  • 1612 views

Hi,

I've been using doScript recently, because I want to be able to undo my script (which makes many changes) by pressing ctrl-z once.

The thing is, as far as I can see, you have to turn the entire script into a string, which means going to the end of the line and deleting the linebreak.

(I'm avoiding putting the script in a file and calling that file, because I want to be able to send this script to other people with minimum hassle.)

Is there any quick way of turning a 30-line script into one long string?

Thanks,

Ariel

This topic has been closed for replies.

2 replies

Harbs.
Legend
June 2, 2009

You do  not need to turn the script into a string.

Here's what you do...

app.doScript (main, undefined, undefined,UndoModes.FAST_ENTIRE_SCRIPT, "My Fancy Script");

function main(){

   //your script body here...

}

Harbs

TᴀW
TᴀWAuthor
Legend
June 2, 2009

Thanks Harbs!

That works perfectly.

Thomas, I see your idea was halfway there!

Thanks,

Ariel

id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators
interesting_Flower157F
Inspiring
June 2, 2009

Untested, but perhaps it will do the trick

app.doScript("myFunction();",ScriptLanguage.JAVASCRIPT);

function myFunction() {
    alert("Function was called");
}

I think i have read that you can actually disable the undo history while the script runs, so only the script itself will be in the history.

--

Thomas B. Nielsen

http://www.nobrainer.dk

TᴀW
TᴀWAuthor
Legend
June 2, 2009

Thanks Thomas,

It doesn't seem to work. But nice idea.

If there is a way to disable the undo history, then that's definitely what I'm looking for. I did do a search, and all I found was this technique of using doScript.

Thanks,

Ariel

id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators