This content has been marked as final. Show 4 replies
Either of the following lines will get you a reference to the next paragraph:
var nPgf = oPgf.insertionPoints[-1].paragraphs;
var nPgf = oPgf.parentStory.paragraphs.nextItem (oPgf);
I have found out that multiple use of nextItem() can slow down the processing of a script.
So I often use a workaround like this to get the next paragraph of a found paragraph within a story (not within a footnote):
// found paragraph
var myPara = myFoundItems[i];
// count of paragraphs from the beginning of a story until the found paragraph
var myParaIndex = myFoundItems[i].parentStory.insertionPoints.itemByRange( 0, myPara.index ).paragraphs.length;
// paragraph after the found paragraph
var myNextPara = myFoundItems[i].parentStory.paragraphs[myParaIndex + 1];
next/previousItem() can get slow indeed. Interesting solution you have there. But I think that that first line I gave is quicker because it doesn't refer to the parentStory and all the paragraphs in it: nPgf = oPgf.insertionPoints[-1].paragraphs;
of course, you are right.
I should have read your message with more strength.