Skip to main content
Roy Marshall
Known Participant
July 22, 2009
Answered

[JS][CS3] Script Librarys

  • July 22, 2009
  • 1 reply
  • 828 views

Hi.

I am going to be embarking on a large scripting project soon, and would like to know if there is any way I can point a script to a different script file containing my commonly used functions.  This is something similar to (as my failing memory recalls) in c++, having the #include........ line at the top of the code.

If this can be done, great, but if not, I can live with using simple functions in the one main script.

Cheers

Roy

This topic has been closed for replies.
Correct answer Laubender

Hi, Roy!

Check the following file of the InDesign CS3 SDK:

javascript_tools_guide_cs3.pdf

p216 "Modular Programming Support"

Excerpt:

"ExtendScript provides support for a modular approach to scripting by allowing you to include one script in
another as a resource, and allowing a script to export definitions that can be imported and used in another
script."

also see the following file of the InDesign CS4(!) SDK:

ar42s03s03.html

"Loading external scripts"

Excerpts:

"ExtendScript has an #include feature you can use to include an external JavaScript file, so the functions in the include file are available for the locale script to use; however, you cannot use it to load a compiled binary script. If you want to distribute your JavaScript feature in binary format like Export as XHTML, you cannot use #include to load an external JavaScript file."

"In CS3, Export as XHTML’s source has a function called loadScript()"

Greetings,

Uwe

1 reply

LaubenderCommunity ExpertCorrect answer
Community Expert
July 23, 2009

Hi, Roy!

Check the following file of the InDesign CS3 SDK:

javascript_tools_guide_cs3.pdf

p216 "Modular Programming Support"

Excerpt:

"ExtendScript provides support for a modular approach to scripting by allowing you to include one script in
another as a resource, and allowing a script to export definitions that can be imported and used in another
script."

also see the following file of the InDesign CS4(!) SDK:

ar42s03s03.html

"Loading external scripts"

Excerpts:

"ExtendScript has an #include feature you can use to include an external JavaScript file, so the functions in the include file are available for the locale script to use; however, you cannot use it to load a compiled binary script. If you want to distribute your JavaScript feature in binary format like Export as XHTML, you cannot use #include to load an external JavaScript file."

"In CS3, Export as XHTML’s source has a function called loadScript()"

Greetings,

Uwe

Roy Marshall
Known Participant
July 23, 2009

Hi Uwe.

Thanks for that solution.

That was really easy!!!! and I will use this feature to keep my common code in one place.

Thanks again matey,

Roy