4 Replies Latest reply on Nov 26, 2012 3:29 AM by Vamitul

    alternative to nextItem()?

    Vamitul Level 4

      As it was mentioned on numerous ocasions in this forum, the nextItem() and previousItem() are painfully slow. Found this out for myself this days, when running a script i'we made for side headers in a 900 page long story. Six hours and change to make about 11000 anchored text frames.

       

      So, i'm on the hunt for an alternative for the said methods. Especialy for paragraphs - for a selected paragraph, how can i get a reference to the next paragraph in the story? Would be nice if it is something more generic, to work for characters, for example might be nice, but i'll take any help i can!

       

      Thanks all

        • 1. Re: alternative to nextItem()?
          [Jongware] Most Valuable Participant

          Vamitul wrote:

           

          Six hours and change to make about 11000 anchored text frames.

           

          Reminds me of the ol' days, adjusting automatic headers with Pagemaker and its incredibly complicated scripting language in books surpassing 600 pages -- I think I took up smoking around that time.

           

          A preliminary answer, I'm sure there are better ways:

           

          p = app.selection[0].paragraphs[0];
          next_p = p.parentStory.characters[p.paragraphs[0].characters[-1].index+1].paragraphs[0];
          
          2 people found this helpful
          • 2. Re: alternative to nextItem()?
            Vamitul Level 4

            shamelessly ripping off Harbs:

            Paragraph.prototype.nextP= function(){
                return this.paragraphs[-1].insertionPoints[-1].paragraphs[0];
            }
            

            New script run time: 46 minute. Makes me wonder how does the "nextitem()" method realy works that is so so slow..

             

             

            used to love PMaker scripting. Had an awesome scripted workflow, that generated a 24 page magazine with a click of a button. All i had left to do was simple adjustments to the layout (mostly manual hyphenation and widow/orphan control).

            1 person found this helpful
            • 3. Re: alternative to nextItem()?
              Peter Kahrel Adobe Community Professional & MVP

              Beware that if you use that function on the last paragraph in a story, it returns itself.

               

              Peter

              • 4. Re: alternative to nextItem()?
                Vamitul Level 4

                yep. for now, it's not a problem, but i will change it when i'll add it to my library.

                what does nextItem() return when it's the last paragraph? undefined?

                a easy way of checking if it's the last para in story?

                does this work?

                if (this === this.parentStory.paragraphs[-1]){return undefined} \

                sorry, can't check now as all of my computers are running the script..

                1 person found this helpful