This content has been marked as final.
Show 3 replies
-
1. Re: [JS] [CS3 onwards] Simplify some code
Fred Goldman May 5, 2010 8:50 PM (in response to Roy Marshall)It would most likely be a lot faster if you did a findText() instead of looping through all the paragraphs.
-
2. Re: [JS] [CS3 onwards] Simplify some code
Dave Saunders May 6, 2010 7:57 AM (in response to Roy Marshall)Roy,
I sometimes use this approach to processing a story. Usually, I'll have a large switch that operates on the appliedParagraphStyle.name property. But, unfortunately, this:
myStory = app.selection[0].parentStory; myPSnames = myStory.paragraphs.everyItem().appliedParagraphStyle.name;
Doesn't work. So, instead, I use:
myStory = app.selection[0].parentStory; myPstyles = myStory.paragraphs.everyItem().appliedParagraphStyle; for (var j = myPstyles.length - 1; j >= 0; j--) { switch (myPstyles[j].name) { case ... case ...etc.
Dave
-
3. Re: [JS] [CS3 onwards] Simplify some code
Dave Saunders May 6, 2010 7:59 AM (in response to Dave Saunders)Now I think about it, when processing a story in this fashion, it doesn't matter a lot whether you go forwards or backwards through the story. I wrote the loop in the example above to go backwards out of habit, but when you're accessing paragraphs by index in the story, as long as you don't change the number of paragraphs, you can loop either way.
Dave


