Beenden
  • Globale Community
    • Sprache:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

restoring findGrepPreferences

Berater ,
Aug 24, 2012 Aug 24, 2012

hello!

i have something like this:

var old_fCGOpts=app.findChangeGrepOptions;

var old_fGPref=app.findGrepPreferences;

var old_cGPref=app.changeGrepPreferences;

app.findChangeGrepOptions=NothingEnum.NOTHING;

app.findGrepPreferences=NothingEnum.NOTHING;

app.changeGrepPreferences=NothingEnum.NOTHING;

// do some stuff

// trying to restore the preferences

app.findChangeGrepOptions=old_fCGOpts;

app.findGrepPreferences=old_fGPref;

app.changeGrepPreferences=old_cGPref;

I get the folowing error:

Invalid value for set property "findChangeGrepOptions". Expected NothingEnum enumerator, but recived FindChangeGrepOption.

Help! It's driving me nuts.

THEMEN
Skripterstellung
1.6K
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines

correct answers 1 richtige Antwort

Mentor , Aug 25, 2012 Aug 25, 2012

Hi Vamital

This is what you were looking for!

old_cGPref = app.changeGrepPreferences.properties;

app.changeGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences.
properties = old_cGPref;

You needed to add "properties".

BTW a little sort cut

app.findChangeGrepOptions = app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;

Trevor

Übersetzen
Beitragender ,
Aug 25, 2012 Aug 25, 2012

Hello Vamitul,

i think you cannot set all the properties in this way.

But try this for findChangeGrepOptions:

with (app) {  

    with (findChangeGrepOptions) {  

      var _userIncludeFootnotes = includeFootnotes;

      var _userIncludeHiddenLayers = includeHiddenLayers;

      var _userIncludeLockedLayersForFind = includeLockedLayersForFind;

      var _userIncludeLockedStoriesForFind = includeLockedStoriesForFind;

      var _userIncludeMasterPages = includeMasterPages;   

    } 

    //  do some stuff 

    with (findChangeGrepOptions) {    

      includeFootnotes = _userIncludeFootnotes;

      includeHiddenLayers = _userIncludeHiddenLayers;

      includeLockedLayersForFind = _userIncludeLockedLayersForFind;

      includeLockedStoriesForFind = _userIncludeLockedStoriesForFind;

      includeMasterPages = _userIncludeMasterPages;   

    }

}

or this:

app.findChangeGrepOptions.properties = { includeFootnotes:_userIncludeFootnotes, ... };

app.findGrepPreferences has over 200 properties! For this you can use a loop and ".reflect.properties".

Best regards

Roland

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Mentor ,
Aug 25, 2012 Aug 25, 2012

Hi Vamital

This is what you were looking for!

old_cGPref = app.changeGrepPreferences.properties;

app.changeGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences.
properties = old_cGPref;

You needed to add "properties".

BTW a little sort cut

app.findChangeGrepOptions = app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;

Trevor

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Berater ,
Aug 26, 2012 Aug 26, 2012

thanks Trevor.

It worked.

I know about the shortcut (i actually learned it looking through some of your and Marc's scripts). i'm trying as hard as i can not to use any such shortcuts, as my coding is already very very messy, unindented, with poorly named variables etc. and i often come to the situation when i have to modify a script after 3-4 months, and i end up rewriting it because i can't remember that the .... i was doing in it. Actually this shortcut is easy and straightforward, but.. using them is just like cigarettes... just one more..

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Berater ,
Aug 26, 2012 Aug 26, 2012

ok.. another question:

how tho check if selection is any kind of text:

    if (app.documents.length != 0 && app.selection.length != 0 &&

      (app.selection[0].constructor.name=="Text"||app.selection[0].constructor.name=="Paragraph"))

but sometimes selection is "textStyleRange", sometimes is "character" etc. is there any shortcut to check everything at once?

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Mentor ,
Aug 26, 2012 Aug 26, 2012
AKTUELL

Hi Vamitul

Start another thread.

This question is a little bit off the topic

Trevor

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines