Article View: adobe.scripting.indesign
Article #2498[IDCS3] [JS] Access/Retrieve part of a Story by Index
From: gfellenz
Date: Sat, 13 Dec 2008 16:00
Date: Sat, 13 Dec 2008 16:00
32 lines
1809 bytes
1809 bytes
hi all,
want to add some sort of logging to find/change operations. the idea was to write a csv-log like:
findWhat,changeTo,surrounding text before,surrounding text after
this would be especially useful for checking grep find/change operations, because they can produce accidental replacements.
so far i've no idea how to access an story object by index. my idea is to select the text based on the insertionPoints i retrieve from the find/change results:
app.findGrepPreferences.findWhat = "\\t(\\d+)";
var _findErg = app.activeDocument.findGrep ();
for (var i = _findErg.length - 1; i >= 0; i--) {
var index = _findErg[0].index;
app.select(_findErg[0].parentStory.insertionPoints[index - 15])
app.select(_findErg[0].parentStory.insertionPoints[index + 15], SelectionOptions.ADD_TO)
$.writeln (app.selection[0].contents);
}
this works fine (i know there will be some more checking for production use to avoid getting out of bounds etc, but this is a second point).
wonder if there is any more elegant/efficient method to access the textrange?
i've no idea how to achieve this with a story or text object, thought of sth. like:
app.texts.get(InsertionPoint,InsertionPoint)
any ideas?
thanks in advance,
gregor
Technical Details
Message-ID:
<59b74298.-1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossingShow Full Headers
Complete Article Headers
X-Google-Thread: f939a,851dc1f147eb570b,start X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: gfellenz@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: [IDCS3] [JS] Access/Retrieve part of a Story by Index Message-ID: <59b74298.-1@webcrossing.la2eafNXanI> Date: Sat, 13 Dec 2008 08:00:49 -0800 Lines: 40 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit