2 Replies Latest reply on Jul 23, 2009 4:29 AM by Roy Marshall

    [JS][CS3] Script Librarys

    Roy Marshall Level 1

      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

        • 1. Re: [JS][CS3] Script Librarys
          Laubender Adobe Community Professional & MVP

          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

          • 2. Re: [JS][CS3] Script Librarys
            Roy Marshall Level 1

            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