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

restoring findGrepPreferences

Advisor ,
Aug 24, 2012 Aug 24, 2012

Copy link to clipboard

Copied

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.

TOPICS
Scripting

Views

1.4K

Translate

Translate

Report

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

Guru , 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

Votes

Translate

Translate
Contributor ,
Aug 25, 2012 Aug 25, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Guru ,
Aug 25, 2012 Aug 25, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Advisor ,
Aug 26, 2012 Aug 26, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Advisor ,
Aug 26, 2012 Aug 26, 2012

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

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
Guru ,
Aug 26, 2012 Aug 26, 2012

Copy link to clipboard

Copied

LATEST

Hi Vamitul

Start another thread.

This question is a little bit off the topic

Trevor

Votes

Translate

Translate

Report

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