6 Replies Latest reply on Feb 28, 2008 10:04 AM by (Avi)

    Problem in scriptUI

    Level 1
      I am creating a scriptUI. This script is working fine but i am getting problem in placing the path of a file in textpanel(edit text).

      I am posting my script. I am getting problem in variable mypath.
      mypath is a variable which content a file path when i am trying to place this path in textpanel then the expected output should bethe path name in textpanel but i am getting name as file in that textpanel.

      I am trying to use alert for mypath. The output am getting is the path of that file not the name "File".

      My aim is to put path of the file in that textpanel.
      What is wrong with my script.
      Please help me.

      myDlg = new Window('dialog', 'Connect to the master');
      myDlg.size = [200,200];
      myDlg.orientation = 'column';

      myDlg.btn1 = myDlg.add('button', undefined, 'Browse');
      myDlg.msgPnl = myDlg.add('panel', undefined);
      myDlg.msgPnl.titleEt = myDlg.msgPnl.add('edittext', undefined,'Sample Alert');

      myDlg.btn2 = myDlg.add('button', undefined, 'Ok');
      myDlg.closeBtn = myDlg.add('button', undefined, 'Close');

      myDlg.btn1.onClick = function()
      {
      var myPDFFile = File.openDialog("Connect to the master");
      var mypath = myPDFFile;
      alert(mypath);
      if (myDlg.msgPnl.titleEt.text == 'Sample Alert')
      {
      myDlg.msgPnl.titleEt.text = mypath;
      myDlg.closeBtn.enabled = false;
      }
      }

      myDlg.closeBtn.onClick = function()
      {
      this.parent.close(1);
      }
      result = myDlg.show();
        • 1. Re: Problem in scriptUI
          Peter Kahrel Adobe Community Professional & MVP
          Instead of

          var mypath = myPDFFile;

          use

          var mypath = myPDFFile.name;

          Peter
          • 2. Re: Problem in scriptUI
            Level 1
            Using alert to test things can be problematic because it has a built-in coerce-to-string front end, so things can look like strings when they're other things.

            In addition to Peter's suggestion, you could also use:

            var mypath = String(myPDFFile);

            That will trigger the same coercion as alert() uses.

            Dave
            • 3. Re: Problem in scriptUI
              Level 1
              Thank you peter and dave for your help.
              I have one more problem in placing the button in right place.

              I want to place text panel and browse button in a one row and In the next row ok and cancel button.

              How to increase the length of the edittext panel.

              Thank you,

              --Avi
              • 4. Re: Problem in scriptUI
                Peter Kahrel Adobe Community Professional & MVP
                No idea. You can undoubtedly find that in the documentation.

                Peter
                • 5. Re: Problem in scriptUI
                  Level 1
                  Is this what you're looking for?

                  myDlg = new Window('dialog', 'Connect to the master');
                  //myDlg.size = [200,200];
                  myDlg.orientation = 'column';

                  myDlg.btn1 = myDlg.add('button', undefined, 'Browse');
                  myDlg.msgPnl = myDlg.add('panel', undefined);
                  myDlg.msgPnl.titleEt = myDlg.msgPnl.add('edittext', undefined,'Sample Alert');

                  myDlg.msgPnl.preferredSize.width = 180;
                  myDlg.msgPnl.preferredSize.height = 200;
                  var g1 = myDlg.add( "group" );
                  myDlg.btn2 = g1.add('button', undefined, 'Ok');
                  myDlg.closeBtn = g1.add('button', undefined, 'Close');

                  myDlg.btn1.onClick = function()
                  {
                  var myPDFFile = File.openDialog("Connect to the master");
                  var mypath = myPDFFile;
                  alert(mypath);
                  if (myDlg.msgPnl.titleEt.text == 'Sample Alert')
                  {
                  myDlg.msgPnl.titleEt.text = mypath;
                  myDlg.closeBtn.enabled = false;
                  }
                  }

                  myDlg.closeBtn.onClick = function()
                  {
                  this.window.close(1);
                  }
                  result = myDlg.show();

                  Note that in the closeBtn.onClick handler, you should always use the "window" property.

                  Bob
                  • 6. Re: Problem in scriptUI
                    Level 1
                    Yes thank you bob.
                    This is what i am looking for.