4 Replies Latest reply on Feb 27, 2008 1:18 AM by liedzeit

    [AS] How to get reliable scripts folder path

    liedzeit Level 2
      I have a RealBasic Application that needs to call a JavaScript. So I let an AppleScript from within the application do a do Script on the Javascript.

      Basically I have this:

      tell application "Adobe InDesign CS3"
      tell script preferences
      set x to scripts folder & "Checkoutdoc.jsx" as text
      end tell
      display dialog x
      do script alias x language javascript
      end tell

      Testing on my machine I found that scripts folder always returns the path to the scripts folder of the preferences instead of the scripts folder of the application. I found this odd but did not care I just put the Checkoutdoc.jsx there and everything works fine.

      But now testing on a different machine I find that x gets the path to the InDesign Server preferences scripts folder.

      What is a reliable way to get the scripts folder?

      Thank you,
      Ralf
        • 1. Re: [AS] How to get reliable scripts folder path
          Dirk Becker  Level 4
          tell application "Adobe InDesign CS2"
          display dialog (get path to application "Adobe InDesign CS2") as text
          end tell

          You're probably talking to the server. When AppleScripts are compiled, they translate the ( application "blah" ) specifier into a reference using the application's creator type. This creator type is the same for InDesign and InDesignServer. If an application matching the creator type is already running, it is addressed independent from the application name.

          Launch both and run this to see:

          tell application "Finder"
          get name of every process whose creator type is "InDn"
          end tell

          Dirk
          • 2. Re: [AS] How to get reliable scripts folder path
            liedzeit Level 2
            You are right, Dirk. I found that out in the meantime. So the real question is: how do I address Indesign instead of InDesignServer.

            I seem to remember there was a way to get get the right application by means of the process list

            tell applcation "Finder"
            set realapp to first item of every process whose name is "Adobe InDesign CS3"
            end tell

            tell realapp
            activate
            end tell

            But this does not work

            An alternative is to launch the javascript directly from RB but then I get the this annoying dialog: Do you really want to run the script...

            The other question is why does the InDesign Server not run the script. (I got rid of the activate)

            Ralf
            • 3. Re: [AS] How to get reliable scripts folder path
              Dirk Becker  Level 4
              Maybe one of the code snippets below gets you further.
              Otherwise try to make InDesignServer run that Checkoutdoc.jsx - are you seeing any error message?

              Dirk

              tell application "Finder" to set frontmost of (first process whose creator type is "InDn" and name does not contain"Server") to true

              set a to "Adobe InDesign CS3"
              tell application a
              using terms from application "Adobe InDesign CS3"
              do script "alert(app.name)" language javascript
              end using terms from
              end tell
              • 4. Re: [AS] How to get reliable scripts folder path
                liedzeit Level 2
                What now seems to work is this (snippet):

                try
                tell application "Finder" to set realapp to name of (first process whose creator type is "InDn" and name contains "CS3")
                on error
                return "No InDesign running"
                end try

                tell application realapp
                try
                using terms from application "Adobe InDesign CS3"
                do script alias x language javascript
                end using terms from
                end try

                I am not completely happy with this but maybe I should be. Thank you, Dirk.
                Ralf