3 Replies Latest reply on Jun 23, 2008 11:22 PM by (Andy_N.)

    Include one script in another

    Level 1
      Apologies if this is a stupid question , but I'm looking at having a library of javascript functions which will be available to other scripts. However I can't find an obvious way of including one javascript file in another.

      Has anyone else tried this?
        • 1. Re: Include one script in another
          Level 1
          Seem to have found the answer to this.

          If anyone else is trying this you can do e.g.

          #include "Utilities.js";

          (where utilities.js is in the same folder)
          1 person found this helpful
          • 2. Re: Include one script in another
            Level 1
            If you use the statement

            #include "Utilities.js"

            InDesign will look for the library in the **current folder**.
            If you didn't set this folder yourself InDesign mill use it's own location.

            I think it's safer to use an absolute path.

            Grtn, Kees
            • 3. Re: Include one script in another
              Hi there,

              another way to execute an external script is the Application.doScript method.

              Application.doScript(script:any, language: ScriptLanguage , withArguments:Array of any):any

              Executes the script in the specified language.

              script: Data Type: any
              The script to execute. Can accept: File or String.

              language: Data Type: ScriptLanguage , Default Value: UNKNOWN
              The language of the script to execute. If not specified, uses the language used to call this method. (Optional)

              withArguments: Data Type: Array of any
              An array of arguments to pass to the script. (Optional)

              Best wishes
              Andy