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

How do I find the dir with personal settings ?

Advocate ,
Nov 21, 2011 Nov 21, 2011

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

TOPICS
Scripting
2.3K
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

Enthusiast , Nov 21, 2011 Nov 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

Translate
Enthusiast ,
Nov 21, 2011 Nov 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

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
Advocate ,
Nov 21, 2011 Nov 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

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
Advocate ,
Nov 21, 2011 Nov 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

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 ,
Nov 21, 2011 Nov 21, 2011
LATEST

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.)

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
Advocate ,
Nov 21, 2011 Nov 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;

}

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