Seems like a good idea. I modified it a little to give me some idea of what it was doing:
//script is supposed to find the SKUs and write them sequentially to a new document app.findGrepPreferences = app.changeGrepPreferences = null; // set options to in-/exclude footnotes, masters, etc. app.findGrepPreferences.findWhat "[A-H|K-N|R][P|1-9][A-Z|0-9][0-9]{2,4}\>"; //This pattern is our product codes, I want to generate a list of all codes in the document f = app.documents[0].findGrep(); if (f.length > 0) { s = ""; for (i = 0; i < f.length; i++) s += f[i].contents + "\r"; alert("Found " + s); app.documents.add ().textFrames.add ({contents: s, geometricBounds:
["5mm", "5mm", "100mm", "100mm"]}); alert("Search finished."); Else alert("Search string not found"); } ....and apparently the answer to that question is, "Nothing." No error messages, script doesn't blow up, no alerts. Just sits there like a dead crab. Using this basic principle I was able to get the VB.net app I was working on to treat the findGrep() as an array and write its contents to a text file. But the contents of the text file turned out to be: "System.Com_Object" "System.Com_Object"
Etc. for as many SKUs as are in the text. There just ought to be some way to get VB to cast the search results as a string, but I'm dipped if I can figure out what it is.
-----Original Message----- From: InDesign Talk [mailto:indesign@lists.lassosoft.com] On Behalf Of Peter Kahrel Sent: Friday, December 18, 2009 9:30 PM To: InDesign Talk Subject: [SPAM-HEADER] - Re: Scripting FindGrep
Is this what you meant? The JavaScript below finds all numbers of more than one digit and prints them in a new document.
Peter
app.findGrepPreferences = app.changeGrepPreferences = null; // set options to in-/exclude footnotes, masters, etc. app.findGrepPreferences.findWhat = "\\d\\d+"; f app.documents[0].findGrep(); if (f.length > 0) { s = ""; for (i = 0; i < f.length; i++) s += f[i].contents + "\r"; app.documents.add ().textFrames.add ({contents: s, geometricBounds:
["5mm", "5mm", "100mm", "100mm"]}) }
On Sat, 19 Dec 2009 00:25:53 -0000, Kathe Todd <Kathe-T@audioeditions.com> wrote:
> I'm programming for InDesign in VB.Net, which is similar but not > identical to scripting in Vbscript. It seems like I ought to be able > to code the same GREP search I could use in ID's Find GREP tab to find
> matching patterns one at a time, copy them to the clipboard, and then > write them sequentially to a text file. But I've been playing around > with it for a couple of hours and I can't seem to figure out how. > There are darn few references online for using VB.Net to do stuff with ID. > > Isn't there some way to script (either with VB or JS) so that the GREP
> find goes to the first instance, then allows you to copy it and do > something with it before going on to the next? Experiments showed that
> if I included ChangeGrepPreferences it would go through and change > every single instance of the found pattern to whatever I specified in > ChangeTo. Not what I had in mind... > > Kathe Todd > > Audio Editions > > kathe-t@audioeditions.com
-- This list is a free service of LassoSoft: http://www.LassoSoft.com/ Search the list archives: http://www.ListSearch.com/InDesign/Browse/ Manage your subscription: http://www.ListSearch.com/InDesign/
-- This list is a free service of LassoSoft: http://www.LassoSoft.com/ Search the list archives: http://www.ListSearch.com/InDesign/Browse/ Manage your subscription: http://www.ListSearch.com/InDesign/
This site manages and broadcasts several email lists pertaining to Lasso Programming and technologies related and used by Lasso developers. Sign up today!