Article View: adobe.scripting.indesign
Article #14722Re: JS beginners help
From: Peter_Kahrel
Date: Mon, 19 Jan 2004 12:41
Date: Mon, 19 Jan 2004 12:41
27 lines
2042 bytes
2042 bytes
Roy,
It's indeed confusing that there are two types of search, as Dirk points out. So this would work:
myText = app.selection[0].parentStory;
app.myfindPreferences = null;
app.mychangePreferences = null;
myPound = myText("�")
Now myPound is a collection (or array). Your next section doesn't do what you expect because you now do a search on a string (your "myString" is a string), but what you want is to search just one line (that's I suppose what the for-loop is for). .indexOf, by the way, takes just one argument, so you'd have to say
myResult = myString.indexOf("�")
which is the quivalent to
myResult = myString.search("�")
Anyway, myResult is a number, so you can't say myResult.parentLine: objects have parents, numbers and strings don't--quite apart from the fact that parentLine doesn't exist. But your problem is to get a reference to the line in which you found the pound symbol. A bit counter-intuitively, an object of type character has a property Lines, which is a collection with just one item in it, namely, the line in which that character occurs. So myPound[i].lines[0] is the line in which myPounds[i] occurs. So your for-loop could look like this:
for( i=0 ; i < myPound.length ; i++ )
{
myTab = myPound[i].lines[0].search( "*^t" );
if( myTab.length > 0 )
myPound[i].lines[0].appliedParagraphStyle = "Goerge Kidner body text";
}
Peter
Technical Details
Message-ID:
<2ccf45cf.40@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!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-19 05:07:37 PST From: Peter_Kahrel@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: Re: JS beginners help Message-ID: <2ccf45cf.40@webx.la2eafNXanI> Date: Mon, 19 Jan 2004 04:41:58 -0800 References: <2ccf45cf.-1@webx.la2eafNXanI> Lines: 40 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit