4 Replies Latest reply on Aug 5, 2016 4:53 AM by karthiks94217840

    Fix Tab Position

    karthiks94217840 Level 2

      Hi Friends,

       

      I want a script that can fix tab position for starting all paragraph first 3 tabs position only. Otherwise, don't change to other tabs potions.

      (That function working to single line).

       

      I was try some code but not work out and all tab position automatically changed. Please see my code below:

       

      Example:

       

      First tab position - 10 points:

      Second tab position - 30 points:

      Three tab position - 50 points:

       

      var myDoc = app.activeDocument;  
      app.findGrepPreferences = app.changeGrepPreferences = null;  
      app.findGrepPreferences.findWhat = "(\\t\\t\\t)";
      var myFnd = myDoc.findGrep();
      var a = 0;
      for(var i=0;i<myFnd.length;i++)
      {
          var tabstops = myFnd[i].tabStops;
          for(var j =0;j<tabstops.length;j++)
          {
                  tabstops[j].position =  a+=20;
              }
      }
      

       

      Please see my screenshot also below:

       

      11.png

       

      Please suggest friends,

       

       

      Thanks in Advance.

       

        • 1. Re: Fix Tab Position
          Peter Kahrel Adobe Community Professional & MVP

          Do a grep search for ^\\t\\t\\t

           

          In your script, you change all tab stops in a paragraph, not just the ones in your selection. Instead, do something like this:

           

          var tabStops = myFnd[i].tabStops;
          tabStops[0].position = 10;
          tabStops[1].position = 30;
          tabStops[2].position = 50;
          

           

          Peter

          • 2. Re: Fix Tab Position
            karthiks94217840 Level 2

            Hi Pkahrel,

             

            Thank to your replay.

             

            I have add your code in my script. But, not full fill my requirement. First 3 tab position it's working fine. But, continues (tab-4, tab-5, tab-6, .........) tab position is also changed. No need to change other tabbed positions.

             

            Below my merge code:

             

            var myDoc = app.activeDocument;   

            app.findGrepPreferences = app.changeGrepPreferences = null;   

            app.findGrepPreferences.findWhat = "(\\t\\t\\t)"; 

            var myFnd = myDoc.findGrep(); 

            var a = 0; 

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

               var tabStops = myFnd[i].tabStops; 

                tabStops[0].position = 10; 

                tabStops[1].position = 30; 

                tabStops[2].position = 50;   

            }

             

            I am going is right way? Please suggest friends.

             

            Thanks in Advance.

            • 3. Re: Fix Tab Position
              tpk1982 Level 4

              karthik see hwta Peter said in first line

               

              Do a grep search for ^\\t\\t\\t

               

              so use ^, it is missing in your code

              • 4. Re: Fix Tab Position
                karthiks94217840 Level 2

                Hi Friends,

                 

                @Pkahrel: Sorry! My bad time, I have missing your first line comment.

                 

                @TPK: Thanks, you are find out my missing Grep function.

                 

                My requirement Done.

                 

                Thanks to all

                KS