Copy link to clipboard
Copied
Hi all!
This code has a problem on the "rage" definition! … And I don't find why!!
app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.ENTIRE_SCRIPT, "Column Jump! …");
function main()
{
var myDoc = app.activeDocument,
myStories = myDoc.stories.everyItem().getElements(),
S = myStories.length,
myCharStyle = myDoc.characterStyles.item("Red");
for (var s = 0; s < S; s++) {
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "~M";
myColumnBreaks = myStories
.findGrep();myStories
.characters.itemByRange(0, myColumnBreaks[0].index).appliedCharacterStyle = myCharStyle;}
app.findGrepPreferences = null;
}
Thanks for help!
(^/)
Nothing really problematic to me at first sight. You may not want to set the grep find preferences every loop though.
...app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.ENTIRE_SCRIPT, "Column Jump! …");
function main()
{
var myDoc = app.activeDocument,
myStories = myDoc.stories.everyItem().getElements(),
S = myStories.length,
myCharStyle = myDoc.characterStyles.itemByName("Red");
app.findGrepPreferences = app.changeGrepPreferences = null;
app.fin
Copy link to clipboard
Copied
Nothing really problematic to me at first sight. You may not want to set the grep find preferences every loop though.
app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.ENTIRE_SCRIPT, "Column Jump! …");
function main()
{
var myDoc = app.activeDocument,
myStories = myDoc.stories.everyItem().getElements(),
S = myStories.length,
myCharStyle = myDoc.characterStyles.itemByName("Red");
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "~M";
for (var s = 0; s < S; s++) {
myColumnBreaks = myStories
.findGrep();myColumnBreaks.length>0 && myStories
.characters.itemByRange(0, myColumnBreaks[0].index).appliedCharacterStyle = myCharStyle;}
app.findGrepPreferences = null;
}
what's the issue exactly ?
Copy link to clipboard
Copied
Hi Loïc,
You're right!
I've just fixed it with:
if (myColumnBreaks.length !== 0) myStories
.characters.itemByRange(0, myColumnBreaks[0].index-1).appliedCharacterStyle = myCharStyle;
… because there's a story on master pages!
But I prefer yours:
myColumnBreaks.length>0 && myStories
.characters.itemByRange(0, myColumnBreaks[0].index).appliedCharacterStyle = myCharStyle;
… And you're totally right about to set the Grep find prefs out of the loop!
Thanks!
(^/)
Copy link to clipboard
Copied
Hi
… because there's a story on master pages!
Then you should be concerned by
app.findChangeGrepOptions
But I prefer yours:
Not an absolute. Think it avoids an internal scope (if).
… And you're totally right about to set the Grep find prefs out of the loop!
It just doesn't make sense.
Copy link to clipboard
Copied
Loïc,
I could but I could have "blank" pages with empty story among the current pages too. So I prefer your way!
Yes, I often forget this point! Use yours is, for my little brain, a better writing to debug a script (in this case).
This is, imho, "intellectually", more interesting!
Thanks for all! I'm always a newbie but I make efforts! Aha!
(^/)