🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #9682

Re: Variation of Dave's Script in "How To Begin Scripting"

#9682
From: Fred_Goldman
Date: Thu, 20 Jul 2006 14:37
23 lines
2157 bytes
Unfortunately, I'm not familiar with how to adjust the reference (and the Scripting Guide wasn't of any help), so I tried something a little less conventional, and I can't understand why it didn't work.

myDoc = app.activeDocument
myOriginalStyle = app.activeDocument.characterStyles.item("[None]");
myFinalStyle = app.activeDocument.paragraphStyles.item("Paragraph Style 2");
myCstyle = myDoc.characterStyles.itemByName("Side");
app.findPreferences = app.changePreferences = null;
app.findPreferences.appliedCharacterStyle = myCstyle;
myFinds = myDoc.search("", false, false, undefined, {appliedCharacterStyle:myCstyle});
for (var j = myFinds.length - 1; j >= 0; j--) {
myTF = myFinds[j].paragraphs[0].words[3].insertionPoints[0].addAnchor();
}
myFinds2 = myDoc.search("", false, false, undefined, {appliedCharacterStyle:myCstyle});
for (var j = myFinds.length - 1; j >= 0; j--) {
// theText.move(LocationOptions.atEnd, myTF.parentStory);
myAnchStory = myTF.parentStory;
  myFinds2[j].move(LocationOptions.atEnd, myAnchStory);
  myAnchStory.texts[0].applyStyle( myOriginalStyle );
  myAnchStory.texts[0].applyStyle( myFinalStyle,true );
  myAnchStory.recompose()
}

I thought that by making two loops, one for making the frames and the second for moving the text it wouldn't cause a problem. After all, I'm searching a second time after having putting the anchor character. What's wrong with my logic?
Technical Details
Message-ID: <3bc0ed94.18@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.ispa.de!news.ecp.fr!news.stben.net!webcrossing
References: <3bc0ed94.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,c3f000112de732ba
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Fred_Goldman@adobeforums.com
Newsgroups: adobe.scripting.indesign
Subject: Re: Variation of Dave's Script in "How To Begin Scripting"
Message-ID: <3bc0ed94.18@webcrossing.la2eafNXanI>
Date: Thu, 20 Jul 2006 07:37:20 -0700
References: <3bc0ed94.-1@webcrossing.la2eafNXanI>
Lines: 32
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.ispa.de!news.ecp.fr!news.stben.net!webcrossing