Article View: adobe.scripting.indesign
Article #20750Re: Addressing existing frames fails sometimes
From: Shane Stanley
Date: Wed, 05 Jun 2002 07:42
Date: Wed, 05 Jun 2002 07:42
49 lines
2954 bytes
2954 bytes
in article ef8ee17.-1@WebX.aaQKaf7vad4, Kim Kohen wrote:
> I have a problem where ID doesn't seem to be correctly seeing an existing
> frame. The conditional below always returns false - even when the same text
> file is selected:
>
> set myfile to (choose file) as text set thelabel to myfile & "foo" tell
> application "InDesign 2.0.1" tell document 1 if exists (text frame
1 of
> spread 1 whose label is thelabel) then set myframe to (text frame
1 of
> spread 1 whose label is thelabel) place myfile on myframe showing
options
> no retaining formatting yes else set myframe to make text
frame at page 1
> with properties {geometric bounds:{0.3, -109.0, 3.3, 0.0}, label:thelabel}
> place myfile on myframe showing options no retaining formatting
yes end
> if end tell end tell
>
> However, if I remove 'myfile' from 'thelabel' and simply set thelabel to
> 'foo' it returns true (as expected) on a second iteration.
>
> Could there be a limitation on the length of a label or can anyone see any
> other reason why this is failing?
Labels are limited to 32K, so that's not your problem; what you're seeing is
an Apple text/styled text problem. Basically, "(choose file) as text"
doesn't return raw text, but styled text (related to the language, I think).
While this works fine as a label -- your script will work if you say "exists
text frame thelabel of spread 1" -- it causes problems in a whose clause
because the comparison with the (unstyled) name fails.
I don't know if ID can do much about this; maybe Peter B. will jump in and
tell us.
So if you can't say "text frame thelabel", you have to coerce the text to
unstyled text, and the only reasonable way I know of is to use this:
set thelabel to �class ktxt� of (thelabel as record)
This only works in OS X, I think, and in fact you probably need to wrap the
above line in a try/end try if the script is ever to be run in OS 9.
Hopefully the transition to Unicode will soon get rid of this whole mess.
--
Shane Stanley, sstanley@myriad-com.com.au
Technical Details
Message-ID:
<B923FDFC.31E78%sstanley@myriad-com.com.au>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!supernews.com!news-x2.support.nl!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<ef8ee17.-1@WebX.aaQKaf7vad4>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f939a,f88c8b9e5d1d94f2 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-06-05 01:07:36 PST From: Shane Stanley <sstanley@myriad-com.com.au> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!supernews.com!news-x2.support.nl!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Addressing existing frames fails sometimes Message-ID: <B923FDFC.31E78%sstanley@myriad-com.com.au> Date: Wed, 5 Jun 2002 00:42:21 -0700 References: <ef8ee17.-1@WebX.aaQKaf7vad4> Lines: 69 User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.0.3 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit