6 Replies Latest reply on Jun 12, 2011 5:37 AM by Muppet Mark

    CS5 JS File.displayName problem

    canpserra

      I am using a simple function to open a dialog to enter a name for a new Library and File.displayName instance to get the localized name of the referenced file, without the path specification. I have tested this function with Indesign CS4 (Mac and PC) and everything goes fine.

      With CS5, it works in the PC version but does not work with the Mac version. The alert(myLibname); gives a message: XHTML For Digital Editions.

       

      Any idea?

       

      myLib();

      function myLib(){

      // Dialogo para salvar a biblioteca que foi criada.

      app.libraries.everyItem().close();

      var myFile = File.saveDialog ("Enter a name for the new Library", "Indesign: *.indl");

      app.libraries.add(File(myFile));

      myLibname = myFile.displayName;

          alert(myLibname);

      var myLibrary = app.libraries.itemByName(myLibname);

      }

        • 1. Re: CS5 JS File.displayName problem
          John Hawkinson Level 5

          That is quite curious.

          You should not be calling the File() constructor on the return of File.saveDialog() though -- the latter returns a file already. Do you see a change if you simply call app.libraries.add((myFile);?

          • 2. Re: CS5 JS File.displayName problem
            canpserra Level 1

            No John, I tried to call the direct way app.libraries.add((myFile); but received the same message again.

            • 3. Re: CS5 JS File.displayName problem
              Dirk Becker Level 4

              MacOS Classic had a very different way from what is in fashion with nowaday's OSX to specify files and paths. Under the hood InDesign still uses a mixture of the old "Carbon" and the new approach (via ways too many competing wrapper code libraries), and conversions in between. Therefor you'll still occasionally find paths with ":" colon as separator (e.g. in error messages), but more increasingly with the Unix "/" notation.

               

              The effect you're seeing is when in the process of conversion an intermediate string is parsed and the code can't decide whether it is a relative file path in the one notation or the other. In that case the current working directory comes into play, which frequently happens to be the last accessed startup script folder. See yourself in Extendscript console: Folder.current.name => "XHTML  For Digital Editions"

               

              Similarly ugly effects are XSLs not being recognized from XML import preferences, or files being created in the mid of the InDesign application bundle.

               

              Short from filing a bug at Adobe (please do that anyway) I don't have a solution at hand, but I'd try to fool the system and set the current directory to the parent or grand parent folder of myFile before creating the library, or pass myFile in different string forms (absolute or relative path) and so forth. Please tell us if you achieved anything that way.

               

              Dirk

              1 person found this helpful
              • 4. Re: CS5 JS File.displayName problem
                Muppet Mark Level 5

                Could you not just replace 'displayedName' with 'name'?

                • 5. Re: CS5 JS File.displayName problem
                  canpserra Level 1

                  Last night I was reading the ESTK user guide and found that solution by myself. Also find another propertie "localizedName" but it's not listed in the ESTK Core JavaScript Classes....curious. When I tried with "name" everything worked fine. But I still confusing:

                  1. Why displayName works with CS4 (both Windows and Mac).

                  2. Why displayName works with CS5 on Windows?

                   

                  I can't figure that out.

                   

                  Thanks for your answer Mark. It was right.

                  • 6. Re: CS5 JS File.displayName problem
                    Muppet Mark Level 5

                    I tested with displayedName and got the same results as you and others… localizedName returned undefined… just using name worked but Im not too sure what localizing is used for… at least you have it working…