7 Replies Latest reply on Sep 9, 2015 2:30 AM by Ronald63

    find and between change

    hamdifem Level 1

      I want to change in my text frames written in paragraph style "EBT" text

      Between 1 to 3 of "ABC" text

      Between 4 and 7 "BIM" text

      Between 7 and 10 "KLM" text

      should write

      where and how an error

       

      var myDoc = app.activeDocument;
      var myFrame = myDoc.allPageItems;
      for(var i=0;i<myFrame.length;i++){
      //if(myFrame[i].appliedObjectStyle == tmc) {
      //if(i==5){break;}
      app.findGrepPreferences = app.changeGrepPreferences = null; 
      app.findGrepPreferences.appliedParagraphStyle = "myParS";
      app.findGrepPreferences.findWhat = "EBT";
      if ((i > 0) && (i <= 3)) {var changeX = app.changeGrepPreferences.changeTo  = "ABC";}
      if ((i > 3) && (i <= 7)) {var changeX = app.changeGrepPreferences.changeTo  = "BIM";}
      if ((i > 7) && (i <= 10)) {var changeX = app.changeGrepPreferences.changeTo  = "KLM";}
      myFrame[i].texts[0].changeGrep(); 
      app.findGrepPreferences = app.changeGrepPreferences = null; 
      
      
        • 1. Re: find and between change
          Ronald63 Level 4

          Hi,


          1- it lacks a hook closure at the end "}"


          2- you do not process myFrame[0] in your code, if this frame content "EBT", it will be erased

          if ((i > 0) && (i <= 3)) {var changeX = app.changeGrepPreferences.changeTo  = "ABC";}
          

           


          • 2. Re: find and between change
            hamdifem Level 1

            there I noticed the error

            all the "ABC" doing text

            if the end of the "break continue" Did I need to add

            • 3. Re: find and between change
              Ronald63 Level 4

              Sorry but i don't understand your problem ...

              • 4. Re: find and between change
                hamdifem Level 1

                the problem is to place the order

                but I was able to solve a number of rotating post (parseInt)

                 

                var myDoc = app.activeDocument;

                var myFrame = myDoc.allPageItems;

                for(var i=0;i<myFrame.length;i++){

                app.findGrepPreferences = app.changeGrepPreferences = null; 

                app.findGrepPreferences.appliedParagraphStyle = "myParS";

                app.findGrepPreferences.findWhat = "EBT";

                var j = parseInt(myFrame[i].texts[0].contents, 10);  //****************** + ****************

                if ((j > 0) && (j <= 3)) {app.changeGrepPreferences.changeTo  = "ABC";}

                if ((j > 3) && (j <= 7)) {app.changeGrepPreferences.changeTo  = "BIM";}

                if ((j > 7) && (j <= 10)) {app.changeGrepPreferences.changeTo  = "KLM";}

                myFrame[i].changeGrep(); 

                app.findGrepPreferences = app.changeGrepPreferences = null;

                }

                 

                but to stop after 10 "break" command in the summer when the results fiasco

                • 5. Re: find and between change
                  Ronald63 Level 4

                  Have you a screen of your doc ?

                  • 6. Re: find and between change
                    hamdifem Level 1

                    11, and 12 don't change

                     

                                          before                                                                            after

                    ADF1.jpg

                    • 7. Re: find and between change
                      Ronald63 Level 4

                      Dirty solution ... ;-)

                       

                      var myDoc = app.activeDocument;
                      var myFrame = myDoc.allPageItems;
                      
                      for(var i=0;i<myFrame.length;i++){
                          app.findGrepPreferences = app.changeGrepPreferences = null; 
                          app.findGrepPreferences.appliedParagraphStyle = "myParS";
                          app.findGrepPreferences.findWhat = "EBT";
                          var j = parseInt(myFrame[i].texts[0].contents, 10);  //****************** + ****************
                          if ((j > 0) && (j <= 3)) {app.changeGrepPreferences.changeTo  = "ABC"; myFrame[i].changeGrep(); }
                          if ((j > 3) && (j <= 7)) {app.changeGrepPreferences.changeTo  = "BIM"; myFrame[i].changeGrep(); }
                          if ((j > 7) && (j <= 10)) {app.changeGrepPreferences.changeTo  = "KLM"; myFrame[i].changeGrep(); }
                          app.findGrepPreferences = app.changeGrepPreferences = null;
                      }