Article View: adobe.scripting.indesign
Article #14928Re: JS beginners help
From: Dave_Saunders
Date: Fri, 09 Jan 2004 15:52
Date: Fri, 09 Jan 2004 15:52
54 lines
2768 bytes
2768 bytes
Wow, I just realized my tutorials don't have many (if any) searches. Here are some examples that should help (picked at random from a long script):
myAstyle = myDoc.paragraphStyles.item("++Author_year")
app.findPreferences = null;
app.changePreferences = null;
myStory.search("^p^p",false,false,"^p�^p",{appliedParagraphStyle:myAstyle});
myCstyle = myDoc.paragraphStyles.item("+++number_sequence");
app.findPreferences = null;
app.changePreferences = null;
myStory.search("�",false,false,undefined,undefined,{appliedParagraphStyle:myCstyle});
app.findPreferences = null;
app.changePreferences = null;
myStory.search("�",false,false,"");
myParaStyles = ["addr", "attr", "cat", "col", "dat", "dim", "ill", "med", "not", "num", "pri", "titl"];
myRunins = ["ad^t", "at^t", "ca^t", "co^t", "da^t", "di^t", "il^t", "m^t", "nt^t", "no^t", "pr^t", "ti^t"];
app.findPreferences = null;
app.changePreferences = null;
for (i=0; i<myParaStyles.length; i++) {
myText = myRunins[i];
myPstyle = myDoc.paragraphStyles.item(myParaStyles[i]);
myStory.search(myText, false, false, undefined, undefined, {appliedParagraphStyle:myPstyle});
}
//replace temporary separators with em-dashes
app.findPreferences = null;
app.changePreferences = null;
myStory.search("|", false, false, "^m");
//two things to do to author dates:
// 1. assign no break using date character style
app.findPreferences = null;
app.changePreferences = null;
myPstyle = app.documents[0].paragraphStyles.item('++Author_year');
myCstyle = app.documents[0].characterStyles.item('--Date');
myStory.search('^9^9^9^9-^9^9^9^9',false,false,undefined,{appliedParagraphStyle:myPstyle},{appliedCharacterStyle:myCstyle});
myStory.search('^9^9^9^9-ca. ^9^9^9^9',false,false,undefined,{appliedParagraphStyle:myPstyle},{appliedCharacterStyle:myCstyle});
//2. convert hyphens to en-dashes
app.findPreferences = null;
app.changePreferences = null;
myStory.search('-',false,false,'�',{appliedParagraphStyle:myPstyle,appliedCharacterStyle:myCstyle});
Hope this helps.
Dave
Technical Details
Message-ID:
<2ccf45cf.1@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!fu-berlin.de!solnet.ch!solnet.ch!news.imp.ch!news.imp.ch!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webxReferences:
<2ccf45cf.-1@webx.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f939a,613db9f5b5ffc527 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2004-01-09 08:08:00 PST From: Dave_Saunders@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!fu-berlin.de!solnet.ch!solnet.ch!news.imp.ch!news.imp.ch!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: Re: JS beginners help Message-ID: <2ccf45cf.1@webx.la2eafNXanI> Date: Fri, 9 Jan 2004 07:52:42 -0800 References: <2ccf45cf.-1@webx.la2eafNXanI> Lines: 63 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit