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

Question regarding doScript (InDesign CS4)

People's Champ ,
Jun 02, 2009 Jun 02, 2009

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

TOPICS
Scripting
1.6K
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
Engaged ,
Jun 02, 2009 Jun 02, 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

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
People's Champ ,
Jun 02, 2009 Jun 02, 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

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 ,
Jun 02, 2009 Jun 02, 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

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
People's Champ ,
Jun 02, 2009 Jun 02, 2009
LATEST

Thanks Harbs!

That works perfectly.

Thomas, I see your idea was halfway there!

Thanks,

Ariel

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