5 Replies Latest reply on Aug 26, 2012 11:02 PM by Trevorׅ

    restoring findGrepPreferences

    Vamitul Level 4

      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.

        • 1. Re: restoring findGrepPreferences
          drerol74 Level 2

          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

          • 2. Re: restoring findGrepPreferences
            Trevorׅ Adobe Community Professional

            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

            • 3. Re: restoring findGrepPreferences
              Vamitul Level 4

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

              • 4. Re: restoring findGrepPreferences
                Vamitul Level 4

                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?

                • 5. Re: restoring findGrepPreferences
                  Trevorׅ Adobe Community Professional

                  Hi Vamitul

                   

                  Start another thread.

                  This question is a little bit off the topic

                  Trevor