3 Replies Latest reply on Jun 23, 2009 10:58 PM by dhishok

    doScript with ScriptUI

    srakete Level 1
      Hi,
      I want to use doScript in a ScriptUI dialog, but I cannot get it to run because "a modal dialog is active". I have tried to close the dialog before I run doscript, but no success:

      myDlg = new Window('dialog', 'app.doScript');
      myDlg.orientation = 'column';

      myDlg.btn1 = myDlg.add('button', undefined, 'OK');

      myDlg.btn1.onClick = function()
      {
      var myScriptPath = "Macintosh HD/test.jsx";
      var myScriptFile = new File (myScriptPath);
      app.doScript( myScriptFile, ScriptLanguage.javascript);
      alert("ausgeführt");
      }

      myDlg.show();

      Thanks Stefan
        • 1. Re: doScript with ScriptUI
          Level 1
          That dialog will never go away, and lock the scripting engine for good.

          As for why doScript won't work, I dunno. But I assume it has something to do with the way doScript is implemented in ID. As you know, if you have a modal dialog visible in ID and attempt to run a script from the ESTK in ID you will get the same error.

          But you don't need doScript. You can run any js code you want in the button's onClick handler.

          myDlg.btn.onClick = function() {
          this.window.close( 1 );
          }

          if ( myDlg.show() == 1 ) {
          var myScriptPath = "Macintosh HD/test.jsx";
          var myScriptFile = new File (myScriptPath);
          app.doScript( myScriptFile, ScriptLanguage.javascript);
          }

          That should work because the modal is gone.

          Another way:

          myDlg.btn.onClick = function() {
          var myScriptPath = "Macintosh HD/test.jsx";
          var myScriptFile = new File (myScriptPath);
          $.evalFile( myScriptFile );
          }

          In the case of JavaScript only, $evalFile will cause a JS file to be executed.

          Again, the way the above code is written, the dialog will never go away.

          Bob
          • 2. Re: doScript with ScriptUI
            srakete Level 1
            Thanks Bob, works fine now.
            Stefan
            • 3. Re: doScript with ScriptUI
              dhishok Level 1

              Hi Stefan,

               

              Which means you trying to doScript through ESTK or something else...

              How the scriptUI used with javascripting? can you please explain about ScripUI...

               

               

              Regards

              Thiyagu