Article View: adobe.scripting.indesign
Article #2013Re: (JS) Find Page of Object
From: Harbs
Date: Tue, 13 Jan 2009 11:40
Date: Tue, 13 Jan 2009 11:40
39 lines
2181 bytes
2181 bytes
> If anyone can knock a hole in the above script, I'd be very interested in hearing about it. > What a fun challenge! ;) Besides the unnecessary case (which you mentioned already): 1) AFAIK, every object has a valid parent, even the app itself has itself as a parent -- itself. There's no way to get through the loop a second time with "null". I would do a while(theObj) without any conditions because once you made it in, you can't get out without either returning null or getting your page. I'd just add a case of Page and return theObj and at the end of the function return null 2) Also, "if (theObj == null)" is probably not technically correct. "if (theObj == undefined)" is more accurate (since the only way to get there is with an undefined text frame). (Although I'd just use if(!theObj) for the sake of brevity...) 3) It does not deal with references to Footnotes (although it will work if given a reference to the text inside a footnote). 4) Your function does not deal with notes. It will not find the page a note is on, and will error if given a reference to text inside a note. 5) You can make the function infinitely more useful by adding a second argument which could accept any InDesign object which can contain objects (like Spread, MasterSpread, TextFrame, etc.) I usually want to find the location of the last text frame on overset text, so I prefer to use (a variation of) jxswm's version of the function (which finds the last text frame). -- Harbs http://www.in-tools.com
Technical Details
Message-ID:
<811E88AFBB8EBA4EBA91B195C99ED4E5@in.webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!webcrossingReferences:
<59b77ee3.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,54700b22cee37b94 X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Harbs Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: (JS) Find Page of Object Message-ID: <811E88AFBB8EBA4EBA91B195C99ED4E5@in.webcrossing.la2eafNXanI> Date: Tue, 13 Jan 2009 03:40:08 -0800 References: <59b77ee3.-1@webcrossing.la2eafNXanI> Lines: 47 User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421) MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit