5 Replies Latest reply on May 5, 2009 3:40 PM by Harbs.

    [cs3] Passing values back from "do javascript" to AS

    Eric @ MCA Level 3

      Hi folks,


      I am betting this has been discussed before but the search engine is batting a 0 today, so...


      I have an Applescript that needs to call Bridge and display a Script UI dialog. Easy enough even for a JS amateur like me and I have that part working well. However, I think I am missing something either in the JS itself or the way I am calling it from AS such that I get a value passed back into AS.


      My AS code is something like:

      set jsPath to alias "Path:To:Scripts:Folder:slugDialog.jsx"
      set slugDialogJSX to ""
      --Read the javascript
      set thisFile to open for access jsPath without write permission
      set slugDialogJSX to read thisFile
      close access thisFile
      --Do the javascript
      tell application "Bridge CS3"
          set jsResults to do javascript slugDialogJSX
      end tell
      --Process the results
      if jsResults ≠ "" then
          --would do stuff, but jsResults is always undefined!
      end if


      And loosely, my Javascript goes like:

      #target bridge
      var finalVal = metaSlugger();
      function metaSlugger() {
          // do stuff
          return someString;


      I suspect I simply need to do some final step to have the JS pass the value back, but I'm getting hung up on JS n00bness here.


      If I try "return finalVal" it complains that I am trying to return outside a function?


      Thanks in advance,