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.
Hi Vamital
This is what you were looking for!
old_cGPref
=
app.changeGrepPreferences
.properties;
app.changeGrepPreferences = NothingEnum.NOTHING;
properties
app.changeGrepPreferences.= old_cGPref;
You needed to add "properties".
BTW a little sort cut
app.findChangeGrepOptions = app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
Trevor
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
Copy link to clipboard
Copied
Hi Vamital
This is what you were looking for!
old_cGPref
=
app.changeGrepPreferences
.properties;
app.changeGrepPreferences = NothingEnum.NOTHING;
properties
app.changeGrepPreferences.= old_cGPref;
You needed to add "properties".
BTW a little sort cut
app.findChangeGrepOptions = app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
Trevor
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..
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?
Copy link to clipboard
Copied
Hi Vamitul
Start another thread.
This question is a little bit off the topic
Trevor