0 Replies Latest reply on Apr 22, 2008 8:54 AM by CTC Imaging

    (JS)(CS3) eventListeners: afterOpen UNSTABLE

    CTC Imaging Level 1
      Hello everyone,

      I was able to emulate what inEventScript CS2 plug-in did, using the EventListener new function build into CS3. UNFORTUNATELY as soon as I close the document(s), InDesign crashes. The script is reliable as it has been used in CS2 for the past 6 months. All I did was to write the script that creates the event. The event gets triggered, the script executes and the handler closes once the script is finished. I can open several Docs. and they all get scripted correctly. It looks like something terminates INCORRECTLY once I close one of the document!

      Any suggestion or input will be greatly appreciated. Alex.

      Here is the EVENT Script.
      ===============================================================
      #target indesign
      #targetengine "session"
      app.scriptPreferences.version = 5.0;

      //******************** BEGIN Main ********************
      main();
      function main()
      {
      //** Number 0
      app.addEventListener( "afterOpen", EventOpen, true);
      }

      function EventOpen (itsEvent)
      {
      app.scriptArgs.set("Event_Listener", itsEvent.parent.toSource());
      var myExeSrcFile = new File (app.scriptArgs.get("Event_Open"));
      if (myExeSrcFile.exists)
      {
      myExeSrcFile.open ('r:(read)')
      app.doScript(myExeSrcFile, ScriptLanguage.javascript);
      myExeSrcFile.close();
      alert ("Finished Execution"); //*** Debug: Confirms HANDLER termination
      }
      else
      alert ("Error! Missing File:\n\n" + myExeSrcFile.fsName);
      return;
      }
      =================================================================
      The scriptArgs are defined during a Startup Script. The "Event_Listener" passes the document opened as an argument to the script and is correctly evaluated w/i the "Event_Open" script.