Re: D'oh-plicate terminology
Re: D'oh-plicate terminology
- Subject: Re: D'oh-plicate terminology
- From: Matt Deatherage <email@hidden>
- Date: Tue, 18 Nov 2003 12:23:04 -0600
On 11/18/03 at 3:27 AM, Shane Stanley <email@hidden> wrote:
>
On Nov 18, 2003, at 6:11 PM, Matt Deatherage wrote:
>
>
> The following script has worked for years in InDesign 2.0.2:
>
>
>
> tell application "InDesign 2.0.2"
>
> tell active document
>
> search story for "text" with find attributes B,
>
> {applied paragraph style:"style name"}
>
> end tell
>
> end tell
>
>
Considering your script doesn't specify *which* story, that's very
>
forgiving of it -- it's presumably ignoring the malformed story
>
reference and searching the document. And are you actually looking for
>
the word "text"?
The actual text or paragraph style does not matter; the search is never taking place because, as I noted:
>
> Now, change "InDesign 2.0.2" to "InDesign CS" and, every time, you
>
> get:
>
>
>
>> InDesign CS got an error: story doesn't understand the search
>
>> message.
>
>
Yes, the code has changed, but the old code will probably work fine
>
anyway. Are you saying it doesn't? What happens differently from
>
2.0.2?
What happens differently from 2.0.2 is just what I said: the script works under 2.0.2, but under 3.0 (CS) it _always_ gives the error "story doesn't understand the search message." So, more explicitly, I am saying it doesn't work.
>
BTW, it's dangerous to do any search without re-setting the change
>
preferences and find preferences, otherwise your change will inherit
>
whatever was last used in the UI. You might check if that's the case
>
this time.
I'm sorry if I wasn't clear, but the problem is not that the "search" command is not finding what I want. The problem is that the "search" command returns an _error_ on each invocation because I can't use "story" as its direct object, no matter how I try. It's not returning an empty list; it's stopping the script.
>
> I'd been led to believe there is some kind of bizarre tell block
>
> terminology I can use to specify which "search" I want, but I can't
>
> figure it out. "Tell story" fails
>
>
As it should -- you have to identify *which* story.
>
>
> as does "set myStory to parent of selection/tell myStory". The Apple
>
> event log continues to show the script using the (K2 /Find) event
>
> instead of the (TeXT/Find) event.
>
>
But does the search work?
The search never takes place - I can't use "story" as the object of the search. As I said just after your comment about identifying "which story," I tried a tell block that specifically addressed the story of the current selection, and it also fails with the exact same error, just with more information (like "InDesign CS got an error: story id 201336 of document "MDJ_20031114 CS.indd" doesn't understand the search message.")
>
So post your script. In English, not code. The codes are a red herring.
I posted a script that fails every time, reduced to the smallest number of lines possible, in good bug-reporting fashion. It still fails. It's at the top of this message, though the "B" character is supposed to be option-l for line continuation.
I can accept that thinking it's a terminology problem may be wandering in the weeds, and in fact, I said so up-front. But rephrasing the question as "are you really searching for 'text'" and "make sure you clear the find preferences" are also red herrings. Again, the problem is not that the search returns something other than what I expect - it's that it generates an error and halts the script because I can't search a story, when the dictionary clearly says I can - and that the *same* script works without fail in InDesign 2.0.2.
To be complete, I tried both your sample scripts:
>
tell application "InDesign CS"
>
set change preferences to nothing
>
set find preferences to nothing
>
tell document 1
>
search with find attributes...
>
end tell
>
end tell
"InDesign CS got an error: document 1 doesn't understand the search message."
>
tell application "InDesign CS"
>
tell document 1
>
set findStyle to paragraph style "whatever"
>
set changeStyle to paragraph style "another"
>
set properties of every text style range of every story whose
>
applied paragraph style is findStyle to {applied paragraph
>
style:changeStyle}
>
end tell
>
end tell
This works without error, but you'll notice it doesn't contain the "search" command that I want. I'm not just trying to replace one paragraph style with another; I'm processing each result, examining it and setting behaviors like drop caps and colors based on the content of the found text.
I suppose I could do something like asking for every text range whose applied paragraph style is the one I want, but I had a working script before, and I'm not anxious to rewrite the logic to use different selectors unless it's absolutely necessary. "Search" _should_ still work, and it doesn't.
On 11/18/03 at 9:50 AM, Jon Pugh <email@hidden> wrote:
>
AppleScript events are composed of two 4 character codes, one for the
>
suite that event appears in and one for the actual event. InDesign
>
(and InCopy) dispatches off the event code ONLY. Thus, these three
>
events are actually all the same, but they are differentiated solely
>
for the dictionary, since they take different sets of parameters
>
depending on which form you desire and which target you address them
>
to.
>
>
So in your case, you presumably want to target a story.
>
>
And lay off the cough medicine while scripting. ;)
Ah, would that it were possible, but the news waits for no one.
I can buy this dispatching explanation, but it confused me. I've got three "search" commands, and one is documented as working on a story, but it always errors out with "story doesn't understand the search message." And now, as Shane's first sample script showed, I can't even get it to search a _document_, even though the event codes AppleScript is sending are _explicitly_ documented as working on the application and document objects.
That makes it clearer that it has nothing to do with duplicate terminology, but I still don't think it was an unreasonable first guess, seeing as I made it before the cold set in. :)
I'm beginning to wonder if there's any direct object that InDesign CS _can_ "search," at least on our production system. :(
--
Matt Deatherage <email@hidden> <
http://www.macjournals.com>
I read this list in digest mode; copy me privately for faster responses
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.