Article View: adobe.scripting.indesign
Article #17157Re: [AS] Am I triggering a known issue, or is this script just written incorrectly?
From: Jay Fraser
Date: Thu, 26 Jun 2003 17:43
Date: Thu, 26 Jun 2003 17:43
22 lines
2766 bytes
2766 bytes
Hey, Eric --
I'm thinking the problem might be the lines...
set myOpenParen to index of (character 1 whose contents = "(") of selection
set myCloseParen to index of (character 1 whose contents = ")") of selection
...I'm not sure what you are trying to do there? You've already set myOpenParen and myCloseParen. The second set just does it again, but it does it to the selection, which is different from myStory. Remember, the selection is something you clicked on w/ your mouse. A script doesn't need to select something to affect it. So, the script might be barreling merrily along, but if you have nothing selected it gets confused, crawls inside its cave and reboots.
Another thing: the "try" is used because the parens might not exist. If they don't exist, the script will do weird things. That's why I had the "If error, set myOpenParen to "" " (Uh, that's 2 double quotes, followed by a third.)The two double quotes say "this is a variable, but it's empty." If you don't do that, the variable myOpenParen either doesn't exist (if this is the first para) or retains the previous value (i.e. the index of the open paren of the paragraph above).
That's why I did the (slighly clunky) If-then thing at the end. I only wanted the text to be changed if the script found both an open paren and a close paren in the para. If it finds neither, it skips the para. If it finds only one, it color-codes the para so you can go back and fix it.
I'm thinking I should have annotated the script more. Sorry!
Oh, one more thing. If something like this happens -- you run the script and the program quits -- you need to open the script in Script Editor, open Controls > Open Event Log. This will give you a list of all the actions the script is doing. But, you won't see very much because the "try" statements don't show up. You'll probably have to remove the "try" thingies to really figure out what's happening.
OK, I'm done now. [grin] It's a slow day, can you tell?
Technical Details
Message-ID:
<1de9b237.0@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de9b237.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,fb399c6421d29800 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-06-26 11:08:23 PST From: "Jay Fraser" <jayfraser@yahoo.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: [AS] Am I triggering a known issue, or is this script just written incorrectly? Message-ID: <1de9b237.0@WebX.la2eafNXanI> Date: Thu, 26 Jun 2003 10:43:35 -0700 References: <1de9b237.-1@WebX.la2eafNXanI> Lines: 41 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit