Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ScriptUI openDialog not working downgrading from CS5.5 to CS4

Explorer ,
Apr 03, 2012 Apr 03, 2012

So here is my newest bit of fun.  The scripts I have been writing have been in CS5.5, but I was informed today that they need to run on CS4.

Most everything seems to be working, except one critical piece. Here is  a quick summary of what I am doing. 

I am opening a window that has two text boxes and two buttons.  The first button opens up a file dialog box that lets the client choose where their XML file is located.  When they select it and click ok, it populates the first text box with the path. 

The second button opens up a folder dialog box that lets the client choose the location of their images folder, and when they click ok, it populates the second text box with the path. 

Everything works peachy in CS5.5.  But when I tried it in CS4, this is what it is doing.  When I choose a file and click OK, it is populating the text box with the word "File".  When I choose a folder, it is populating the second box with the word "Folder"

Here are the relevant functions:

f2.onClick = function()

{

     tf = File.openDialog("Select your XML File","*.xml");

     if (tf != null)

     {

          e2.text = tf;

          tf = tf.fsName;

     }

}

f3.onClick = function()

{

     var tfol = new Folder("~/My Documents")

     tfo = tfol.selectDlg("Get Folder");

     if (tfo != null)

     {

          e3.text = tfo;

          tfo = tfo.fsName;

     }

}

Like I said, this is working fine is CS5.5, but I need to know what is different in CS4 and how to get it to work.

Thanks in advance for all your help.

TOPICS
Scripting
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 04, 2012 Apr 04, 2012

Add a line to your code:

if (tf != null)

     {

     $.writeln (tf.constructor.name);

      e2.text = tf;

      tf = tf.fsName;

     }

And run your script from the ESTK with the console open. You'll see that File is printed. So tf is not a string but a file object. Use e2.text = tf.fsName to display the file's full path name or e2.text = tf.name to show just the name. The same applies to the other function, the one that shows Folder instead of the folder's name.

Peter

Translate
Community Expert ,
Apr 04, 2012 Apr 04, 2012

Add a line to your code:

if (tf != null)

     {

     $.writeln (tf.constructor.name);

      e2.text = tf;

      tf = tf.fsName;

     }

And run your script from the ESTK with the console open. You'll see that File is printed. So tf is not a string but a file object. Use e2.text = tf.fsName to display the file's full path name or e2.text = tf.name to show just the name. The same applies to the other function, the one that shows Folder instead of the folder's name.

Peter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 04, 2012 Apr 04, 2012

Is this a change in File/Folder handling from CS4 to CS5?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 04, 2012 Apr 04, 2012

I doubt it. I can't check in CS4 (uninstalled that one accidentally), but in CS3, CS5, and CS5.5, File.openDialog() returns a file object, not a string, so you'd think that CS4 would, too.

Peter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 04, 2012 Apr 04, 2012
LATEST

Peter, thank you.  that worked perfectly. 

Now I get to fix all of the new problems that have cropped up now that it is running again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines