Article View: adobe.scripting.indesign
Article #15113Re: Painfully Slow Text Operations
From: Dave_Saunders
Date: Sun, 28 Dec 2003 13:08
Date: Sun, 28 Dec 2003 13:08
25 lines
2032 bytes
2032 bytes
One thing that has come out of this is my realization that just because I can use the results of a search to address things directly, it still might be better to construct a way of solving a problem using multiple searches.
I just carved 10 minutes out of the run time of my script (processing 469 samples of data) by changing an interation over the results of a find into three find/replace calls.
Given that the real data has 46,000 entries, this will save a whole lot more than 10 minutes, come the day!
The same tricks one uses in the Find/Replace UI to get at special cases can pay off in scripts, too. In this case, I wanted to change the applied paragraph style of every paragraph that consisted of only a return (later in the script, I populate them).
I did it by:
app.findPreferences = null;
app.changePreferences = null;
myStory.search("^p^p",false,false,"^p�^p",{appliedParagraphStyle:myAstyle});
app.findPreferences = null;
app.changePreferences = null;
myStory.search("�",false,false,undefined,undefined,{appliedParagraphStyle:myCstyle});
app.findPreferences = null;
app.changePreferences = null;
myStory.search("�",false,false,"");
(myAstyle and myCstyle were previously set to references to the appropriate paragraph styles.) In the UI, this kind of thing is second nature, but in scripting, I tend not to think along these lines (at least at first).
Dave
Technical Details
Message-ID:
<2ccf16e7.4@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webxReferences:
<2ccf16e7.-1@webx.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f939a,1d2548d78225dca4 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-12-28 05:37:30 PST From: Dave_Saunders@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: Re: Painfully Slow Text Operations Message-ID: <2ccf16e7.4@webx.la2eafNXanI> Date: Sun, 28 Dec 2003 05:08:16 -0800 References: <2ccf16e7.-1@webx.la2eafNXanI> Lines: 39 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit