5 Replies Latest reply on Nov 21, 2011 2:07 PM by [Jongware]

    How do I find the dir with personal settings ?

    4everJang Level 3

      Hi all,

       

      I can find the user's home directory and the FM install directory but not (yet) the dir where personal settings are stored. On my system this is C:\Documents and Settings\Administrator\Application Data\Adobe\FrameMaker\10 but I this depends on the login name, Frame version and possibly Windows version as well.

       

      Is there an easy method or property to get to this directory ?

       

      Thanks

       

      Jang

        • 1. Re: How do I find the dir with personal settings ?
          Ian Proudfoot Level 3

          Jang,

          Try this in your code.

          var fmUser = new Folder(Folder.userData + '/Adobe/FrameMaker/10');

           

          This returns a folder object that will give the required path.

           

          Ian

          • 2. Re: How do I find the dir with personal settings ?
            Michael Müller-Hillebrand Level 4

            Jang,

             

            What a coincidence, I had to deal with this just recently.

             

            With FrameScript it would be  Session.UserSettingsDir

             

            But the ExtendScript interface does not allow easy access to as many properties as there are, so you have to question the list of all session properties and then find the one you want. I created a function to handle this, bhut currently used it only with this call:

             

            getAppProperty(Constants.FP_UserSettingsDir);

             

            I would gladly accept any hints to improve this function.

             

            - Michael

             

            PS: At the computer of one of my colleagures the call to app.GetProps() crashes FrameMaker.

             

            function getAppProperty(pvNum) {

                      var lvProps = app.GetProps(), lvValue;

                      for (var i=0; i < lvProps.length; i++) {

                if (lvProps[i].propIdent.num == pvNum) {

                  switch (lvProps[i].propVal.valType) {

                    case Constants.FT_Integer:  // 1

                      lvValue = lvProps[i].propVal.ival; // does it work?

                      break;

                    case Constants.FT_String:  // 3

                      lvValue = lvProps[i].propVal.sval;

                      break;

                    default:

                      lvValue = lvProps[i].propVal.sval;

                      break;

                  }

                  return lvValue;

                }

                      }

                      return false;

            }

            • 3. Re: How do I find the dir with personal settings ?
              4everJang Level 3

              Next question is how to list all the files in the found directory. I am getting a little puzzled with the scripting documentation. The Folder object is supposed to have a method getFiles, which returns an array of File objects. But retrieving the names of those Files from the array does not seem to give any defined object. As a newbie in scripting, I am getting lost between generic Javascript stuff and potentially specific behavior of ExtendScript. How do I get from the array of File objects that is supposedly returned from the folder's getFiles method to properties of each individual File object ?

               

              Thanks

               

              Jang

              • 4. Re: How do I find the dir with personal settings ?
                4everJang Level 3

                I found the bug(ger) !

                 

                There is an important difference between the properties Folder.appData and Folder.userData. The first one points at the All Users dir in Windows, whereas the second one points to the dir of the currently logged in user. So I was expecting to read files from a folder that does not exist. The strange thing is that the getFiles method on a non-existing folder returns an array object, instead of returning NULL, as the specs define. Hmmm. That's a way to lead newbie programmers astray...

                 

                It works now and I'm happy, for the moment...

                 

                Jang

                • 5. Re: How do I find the dir with personal settings ?
                  [Jongware] Most Valuable Participant

                  You get an array but its *length* is zero.

                   

                  (http://jongware.mit.edu/Js/pc_Folder.html#getFiles is a bit sparse on this detail.)