9 Replies Latest reply on Apr 29, 2009 4:45 AM by Dave Saunders

    Unable to Use Search

    Dave Saunders Level 4

      I've rendered my InDesign CS4 unable to search. I can't use the findText() or findGrep() (haven't tried the others) and neither can I do the equivalent UI functions.

       

      I'm fairly sure that this is the result of a script I wrote whose purpose is to restore preferences each time I restart InDesign potentially after moving some plug-ins in or out of the Plug-ins folder.

       

      I recall Ole posting a warning about this happening if you attempted to set app.findChangeTextOptions or app.findChangeGrepOptions to null, but I'm not doing that. My script executes:

       

      app["findChangeTextOptions"].properties = eval({includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:true, wholeWord:false, caseSensitive:false, parent:resolve(\"/\")});

       

      and

       

      app["findChangeGrepOptions"].properties = eval({includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:true, parent:resolve("/")});

       

      although the eval string is drawn from a variable, so the actual line of code that does the above is written:

       

      app[prefs[0]].properties = eval(prefs[1]);

       

      where prefs[0] and prefs[1] are strings.

       

      If I change the values in the text file that's driving this lot, I see the corresponding value change in the Find dialog. And yet, no matter what I do, Find cannot match anything.

       

      I'm going to conduct some more experiments but I better post this now before I get logged off.

       

      Dave

        • 1. Re: Unable to Use Search
          Dave Saunders Level 4

          OK, I've confirmed that it is my script that is causing the problem by:

           

          1. Restarting with the four-fingered salute having moved the restorePrefs script out of the startup scripts folder.

           

          2. Creating a document and typing some text into a text frame.

           

          3. Using Find to find something. Worked.

           

          4. I ran my script.

           

          And, voila, Find no longer works. That is: it reports that it cannot find a match.

           

          I wonder if I have somehow setup some obscure findTextPreference that is causing the problem. Time to examine the text file that is driving this.

           

          Dave

          • 2. Re: Unable to Use Search
            Dave Saunders Level 4

            Looking at the findTextPreferences, I see these settings:

             

            findWhat:"",
            appliedCharacterStyle:"",
            appliedParagraphStyle:"",
            firstLineIndent:1851876449,
            leftIndent:1851876449,
            rightIndent:1851876449,
            spaceBefore:1851876449,
            spaceAfter:1851876449,
            balanceRaggedLines:1851876449,
            justification:1851876449,
            singleWordJustification:1851876449,
            autoLeading:1851876449,
            dropCapLines:1851876449,
            dropCapCharacters:1851876449,
            keepLinesTogether:1851876449,
            keepAllLinesTogether:1851876449,
            keepWithNext:1851876449,
            keepFirstLines:1851876449,
            keepLastLines:1851876449,
            startParagraph:1851876449,
            composer:1851876449,
            lastLineIndent:1851876449,
            hyphenateLastWord:1851876449,
            dropcapDetail:1851876449,
            hyphenateAcrossColumns:1851876449,
            keepRuleAboveInFrame:1851876449,
            ignoreEdgeAlignment:1851876449,
            appliedFont:"",
            fontStyle:1851876449,
            pointSize:1851876449,
            leading:1851876449,
            kerningMethod:1851876449,
            tracking:1851876449,
            capitalization:1851876449,
            position:1851876449,
            underline:1851876449,
            strikeThru:1851876449,
            ligatures:1851876449,
            noBreak:1851876449,
            horizontalScale:1851876449,
            verticalScale:1851876449,
            baselineShift:1851876449,
            skew:1851876449,
            fillTint:1851876449,
            strokeTint:1851876449,
            strokeWeight:1851876449,
            overprintStroke:1851876449,
            overprintFill:1851876449,
            otfFigureStyle:1851876449,
            otfOrdinal:1851876449,
            otfFraction:1851876449,
            otfDiscretionaryLigature:1851876449,
            otfTitling:1851876449,
            otfContextualAlternate:1851876449,
            otfSwash:1851876449,
            underlineColor:"",
            underlineGapColor:"",
            underlineTint:1851876449,
            underlineGapTint:1851876449,
            underlineOverprint:1851876449,
            underlineGapOverprint:1851876449,
            underlineType:null,
            underlineOffset:1851876449,
            underlineWeight:1851876449,
            strikeThroughColor:"",
            strikeThroughGapColor:"",
            strikeThroughTint:1851876449,
            strikeThroughGapTint:1851876449,
            strikeThroughOverprint:1851876449,
            strikeThroughGapOverprint:1851876449,
            strikeThroughType:null,
            strikeThroughOffset:1851876449,
            strikeThroughWeight:1851876449,
            otfSlashedZero:1851876449,
            otfHistorical:1851876449,
            otfStylisticSets:1851876449,
            gradientFillLength:1851876449,
            gradientFillAngle:1851876449,
            gradientStrokeLength:1851876449,
            gradientStrokeAngle:1851876449,
            gradientFillStart:1851876449,
            gradientStrokeStart:1851876449,
            otfMark:1851876449,
            otfLocale:1851876449,
            positionalForm:1851876449,
            fillColor:"",
            strokeColor:"",
            appliedLanguage:1851876449,
            kerningValue:1851876449,
            miterLimit:1851876449,
            strokeAlignment:1851876449,
            endJoin:1851876449,
            appliedConditions:1851876449,
            paragraphDirection:1851876449,
            paragraphJustification:1851876449,
            otfOverlapSwash:1851876449,
            otfStylisticAlternate:1851876449,
            otfJustificationAlternate:1851876449,
            otfStretchedAlternate:1851876449,
            characterDirection:1851876449,
            keyboardDirection:1851876449,
            digitsType:1851876449,
            kashidas:1851876449,
            diacriticPosition:1851876449,
            xOffsetDiacritic:1851876449,
            yOffsetDiacritic:1851876449,
            numberingRestartPolicies:resolve("/@find-text-preferences/@numbering-restart-policies"),
            bulletsTextAfter:1851876449,
            appliedNumberingList:1851876449,
            numberingLevel:1851876449,
            numberingFormat:1851876449,
            numberingContinue:1851876449,
            numberingStartAt:1851876449,
            numberingApplyRestartPolicy:1851876449,
            bulletsCharacterStyle:1851876449,
            numberingCharacterStyle:1851876449,
            numberingExpression:1851876449,
            bulletChar:resolve("/@find-text-preferences/@bullet-char"),
            bulletsAndNumberingListType:1851876449,
            parent:resolve("/")

             

            1851876449 is the value of NothingEnum.nothing, so I'm pretty sure I can ignore all those. That leaves me with:

             

            findWhat:"",
            appliedCharacterStyle:"",
            appliedParagraphStyle:"",
            appliedFont:"",
            underlineColor:"",
            underlineGapColor:"",
            underlineType:null,
            strikeThroughColor:"",
            strikeThroughGapColor:"",
            strikeThroughType:null,
            fillColor:"",
            strokeColor:"",
            numberingRestartPolicies:resolve("/@find-text-preferences/@numbering-restart-policies"),

            bulletChar:resolve("/@find-text-preferences/@bullet-char"),

            parent:resolve("/")

             

            Perhaps I should get rid of the three that involve resolving, although I think this could be a red-herring. None of those values look particularly bad. Aha! What I should do is execute each of these preferences individually to see which one breaks find.

             

            Dave

            • 3. Re: Unable to Use Search
              Dave Saunders Level 4

              This is no surprise, but by editing the text file with my saved preferences so that it only operated upon the Find/Change related preferences, I have at least isolated the problem to those 12 sets of preferences out of the complete collection of 77.

               

              Note: should have been 78 but the xmlViewPreferences crash InDesign. In particular:

               

              app.xmlViewPreferences.showAttributes = true (or false)

               

              crashes InDesign CS4.

               

              Dave

              • 4. Re: Unable to Use Search
                Dave Saunders Level 4

                I've narrowed it down to the setting of the options. If I leave those out of the savedPreferences the script restores preferences and Find/Change still works.

                 

                OK, so the short-term solution is to exclude those from the save side so that the restore script never touches the options. Since I've already had to build in a filter for the xmlViewPreferences, it is easy enough to add these to the filtered list. On the other hand, these are a bit more useful than the xmlViewPreferences, so it's a pity I have to exclude them.

                 

                Dave

                • 5. Re: Unable to Use Search
                  Olav Martin Kvern Level 3

                  Hi Dave,

                   

                  For whatever it's worth, I would suspect the bullet/numbering-related properties of bad behavior.

                   

                  Thanks,

                   

                  Ole

                  • 6. Re: Unable to Use Search
                    Dave Saunders Level 4

                    That was my first thought too. It might not be doing what I wanted it to, but it is not causing the problem I started out with. That was definitely the fault of the findChangeTextOptions and findChangeGrepOptions. Which is weird because I set those all the time when running scripts that do searches.

                     

                    But since I set them explicitly each time, there's not much point in regarding them as part of the preferences to be saved/restored at launch time so I've simply excluded them from the save script and so the restore never sees them.

                     

                    Dave

                    • 7. Re: Unable to Use Search
                      Harbs. Level 6

                      Dave,

                       

                      I'd suspect the parent property in the findChange options. Try 

                      deleting that:

                      sourcePrefs = eval(prefs[1]);
                      delete targetPrefs.parent;
                      targetPrefs = app[prefs[0]];
                      targetPrefs.properties = sourcePrefs;
                      

                       

                      FWIW, If you're trying to save prefs and restore them after doing find/

                      change operations, here's the functions which I use:

                       

                      This returns the current properties

                           GetCurrentFindSaveProps = function (){
                                var a,b;
                                var retVal = {};
                                if(kAppVersion<5){
                                     retVal.findPreferences = app.findPreferences.properties;
                                     retVal.changePreferences = app.changePreferences.properties;
                                     }
                                else{
                                     retVal.findChangeTextOptions= app.findChangeTextOptions.properties;
                                     retVal.findTextPreferences = app.findTextPreferences.properties;
                                     retVal.changeTextPreferences = app.changeTextPreferences.properties;
                                     retVal.findGrepPreferences = app.findGrepPreferences.properties;
                                     retVal.changeGrepPreferences = app.changeGrepPreferences.properties;
                                     retVal.findGlyphPreferences = app.findGlyphPreferences.properties;
                                     retVal.changeGlyphPreferences =  
                      app.changeGlyphPreferences.properties;
                                     retVal.findObjectPreferences = app.findObjectPreferences.properties;
                                     retVal.changeObjectPreferences =  
                      app.changeObjectPreferences.properties;
                                     }
                                return retVal;
                                }
                      

                       

                      And this restores them...

                       

                           SetCurrentFindSaveProps = function (props){
                                if(kAppVersion<5){
                                     app.findPreferences.properties = props.findPreferences;
                                     app.changePreferences.properties = props.changePreferences;
                                     }
                                else{
                                     app.findChangeTextOptions.properties= props.findChangeTextOptions;
                                     app.findTextPreferences.properties = props.findTextPreferences;
                                     app.changeTextPreferences.properties = props.changeTextPreferences;
                                     app.findGrepPreferences.properties = props.findGrepPreferences;
                                     app.changeGrepPreferences.properties = props.changeGrepPreferences;
                                     //app.findGlyphPreferences=null;
                                     app.changeGlyphPreferences.properties = props.changeGlyphPreferences;
                                     app.findObjectPreferences.properties = props.findObjectPreferences;
                                     app.changeObjectPreferences.properties =  
                      props.changeObjectPreferences;
                                     }
                                }
                      
                      

                       

                      Harbs

                      http://www.in-tools.com

                      • 8. Re: Unable to Use Search
                        Harbs. Level 6

                        Oh. And Dave,

                         

                        I'm not sure if this is your problem, but...

                         

                        If you check your past emails for one called "Find/Change properties", 

                        you'll see that I discovered that setting findGlyph with properties 

                        kills InDesign's find abilities dead in the water...

                         

                        Harbs

                        http://www.in-tools.com

                        1 person found this helpful
                        • 9. Re: Unable to Use Search
                          Dave Saunders Level 4

                          I was starting to wonder about the parent property. It does no good to try to restore it so perhaps I should filter it out when saving.

                           

                          I did not recall your previous message about findChangeGlyphOptions but that certainly fits the bill here. I'll try restoring the other three and see if it still works.

                           

                          On reflection though, I'm starting to think that my save script simply is more ambitious than is needed. Some of these preferences just aren't worth saving from one launch to another because they are so event related that one always sets them up each time.

                           

                          Thanks,

                           

                          Dave