ExtendScript limit on how many paragraphs can be processed
I received a bug report on my FindChangeFormatsBatch ExtendScript script yesterday where the issue was a crash on two particular documents. Both documents contain a large amount of tables and, because each cell contains at least one paragraph, a large number of paragraphs. One document had over 12,000 paragraphs and the other over 14,200 paragraphs.
I still wasn't sure if the number of paragraphs was the problem so I set up a simple, Portrait document containing a large number of paragraphs. Each paragraph was empty except for an autonumber so I could keep track of the number of paragraphs. Here is the code I ran:
#target framemaker
var doc = app.ActiveDoc;
countPgfs (doc);
function countPgfs (doc) {
var pgf, counter = 0;
pgf = doc.FirstPgfInDoc;
while (pgf.ObjectValid () === 1) {
counter += 1;
pgf = pgf.NextPgfInDoc;
}
alert (counter);
}
The code always ran the first time, even with over 14,000 paragraphs in the document. But it would hang and crash FrameMaker if I tried to run it a second time. I cut my paragraph count back until I could run it over and over without hanging. I ended up at around 12,200 paragraphs, give or take a few. Once I got over that mark, FrameMaker would hang on the second run of the script.
I wonder if anyone else has experimented with ExtendScript and processing large numbers of paragraphs. Any feedback or comments will be appreciated.
-Rick

