Article View: adobe.scripting.indesign
Article #20436Re: Object Reference?
From: Olav Kvern
Date: Wed, 31 Jul 2002 18:56
Date: Wed, 31 Jul 2002 18:56
25 lines
2293 bytes
2293 bytes
Jay-- No, you're doing fine! Keep on asking! peter wrote: "I don't know the original reason for this, but I find it quite confusing. Why should text be the one exception?" I feel the same way, and very strongly agree (you'll find a number of rants from me on this topic in the forum archives<g>). Anyway, it's okay, you're not the only one struggling with text references in AppleScript (it's not a problem if you're scripting InDesign in Windows). The next thing you'll probably run into--when you define a text object reference variable in AppleScript, it's stored as "text from character x to character y of story z". This means that a reference to a paragraph, for example, will go out of date if you add or delete characters before that paragraph. By "out of date," I mean that the object reference no longer points to the same piece of text, and might even point to text that is no longer in your document (whcih will cause a script execution error). (In Windows scripting, this isn't the case--a reference to paragraph 3 remains valid unless you add/delete entire paragraphs before the object.) On either platform, we've learned to iterate backwards through the text objects in stories to keep our text object references from becoming invalid--something like: tell story 1 of document 1 repeat with myCounter from (count paragraphs) to 1 by -1 set myParagraph to object reference of paragraph myCounter --do something with the paragraph end repeat end tell Thanks, Ole
Technical Details
Message-ID:
<ef9f3eb.5@WebX.aaQKaf7vad4>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-04!supernews.com!64.152.100.70.MISMATCH!ps01-sjc1!newsfeeds-atl2!news.webusenet.com!news-hub.siol.net!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<ef9f3eb.-1@WebX.aaQKaf7vad4>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,8b36b876f1d2154b X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-07-31 12:12:57 PST From: "Olav Kvern" <okvern@adobe.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-04!supernews.com!64.152.100.70.MISMATCH!ps01-sjc1!newsfeeds-atl2!news.webusenet.com!news-hub.siol.net!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Object Reference? Message-ID: <ef9f3eb.5@WebX.aaQKaf7vad4> Date: Wed, 31 Jul 2002 11:56:28 -0700 References: <ef9f3eb.-1@WebX.aaQKaf7vad4> Lines: 40 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit