Skip to main content
4everJang
Legend
November 21, 2011
Answered

How do I find the dir with personal settings ?

  • November 21, 2011
  • 2 replies
  • 2222 views

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

This topic has been closed for replies.
Correct answer Ian Proudfoot

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 replies

Michael_Müller-Hillebrand
Legend
November 21, 2011

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.propIdent.num == pvNum) {

      switch (lvProps.propVal.valType) {

        case Constants.FT_Integer:  // 1

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

          break;

        case Constants.FT_String:  // 3

          lvValue = lvProps.propVal.sval;

          break;

        default:

          lvValue = lvProps.propVal.sval;

          break;

      }

      return lvValue;

    }

          }

          return false;

}

Ian Proudfoot
Ian ProudfootCorrect answer
Legend
November 21, 2011

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

4everJang
4everJangAuthor
Legend
November 21, 2011

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

4everJang
4everJangAuthor
Legend
November 21, 2011

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