2 Replies Latest reply on Jul 31, 2009 12:41 AM by Adobe-InDesign CS4

    ID-CS4 -JS - - Can't find using Grep options - Reg.

    Adobe-InDesign CS4 Level 1

      Dear All,

       

        Here I have a doubt about the "Find / Change Grep" in InDesign CS4.

       

      I can find the "Force Line Break" using the Grep options : ([a-zA-Z]*)-\\n([a-zA-Z]*)]

       

      Some time this Grep is working, some time this is not working ...

       

      I don't know what I made the mistakes. Please let me know any one can suggest and modify the below coding.

       

      I supposed to close and re-open the InDesign CS4 and ExtendScript tool, then First time this Grep is working fine...

       

      So I confused this. Please any one can give me a solutions.

       

      //================= Coding ==================//

       

         var myDoc=  app.activeDocument;

             app.findChangeGrepOptions.includeFootnotes = false;
             app.findChangeGrepOptions.includeHiddenLayers = false;
             app.findChangeGrepOptions.includeLockedLayersForFind = false;
             app.findChangeGrepOptions.includeLockedStoriesForFind = false;
             app.findChangeGrepOptions.includeMasterPages = false;

             app.findGrepPreferences.findWhat = "([a-zA-Z]*)-\\n([a-zA-Z]*)";
               mySearch = app.findGrep();
               for(var myForce =0; myForce<mySearch.length; myForce++)
                {
                app.select(mySearch[myForce]);
                var mySel = app.selection[0];
                 myConts = mySel.contents;

                app.select(mySearch[myForce]);
                var mySel = app.selection[0];
                 myConts = mySel.contents;

                app.findGrepPreferences = NothingEnum.nothing;
                 app.changeGrepPreferences = NothingEnum.nothing;
               }

       

      //=============== End of the Coding ========================//

       

       

      Please any one can kindly help me....

       

       

       

      Thanks & Regards

      T.R.Harihara SudhaN

        • 1. Re: ID-CS4 -JS - - Can't find using Grep options - Reg.
          vaasu devi Level 1

          Hi,

           

          Your script is working fine for me in CS3. I don't think so, CS3 and CS4 has much difference in 'find/Change' scripting. If the document has hyphen (-) before the line break, it showing that occurrences. Try like this, place that findGrepPreferences and changeGrepPreferences Nothing after that for loop.

           

           

          vaasu

          • 2. Re: ID-CS4 -JS - - Can't find using Grep options - Reg.
            Adobe-InDesign CS4 Level 1

            Dear Vaasu Devi,

             

              Many thanks for your reply...

             

            I found, where I mistaken....

             

            Here My Correct Code :

             

            //================= Coding ==================//

             

               var myDoc=  app.activeDocument;

                   app.findChangeGrepOptions.includeFootnotes = false;
                   app.findChangeGrepOptions.includeHiddenLayers = false;
                   app.findChangeGrepOptions.includeLockedLayersForFind = false;
                   app.findChangeGrepOptions.includeLockedStoriesForFind = false;
                   app.findChangeGrepOptions.includeMasterPages = false;

                   app.findGrepPreferences.findWhat = "([a-zA-Z]*)-\\n([a-zA-Z]*)";
                     mySearch = app.findGrep();
                     for(var myForce =0; myForce<mySearch.length; myForce++)
                      {
                                app.select(mySearch[myForce]);
                                 myConts = mySearch[myForce].contents;

                                 $.writeln(myConts);
                      app.findGrepPreferences = NothingEnum.nothing;
                       app.changeGrepPreferences = NothingEnum.nothing;
                     }

             

            //=============== End of the Coding ========================//

             

            app.select() is working fine, meanwhile, I get the selection of the contents. That time only its throw the Error message. So I used to divert, app.select and Select Value of Contents to pass the "myConts" variable then I will do the other funtions.... Now My this time I'm not getting the Errors...

             

            Thanks Once again

             

            Regards

            T.R.Harihara SudhaN