Re: D'oh-plicate terminology
Re: D'oh-plicate terminology
- Subject: Re: D'oh-plicate terminology
- From: Shane Stanley <email@hidden>
- Date: Tue, 18 Nov 2003 20:27:41 +1100
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"?
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?
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. Meanwhile, try this:
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
Or if you're not in a hurry and you're looking only for a style, try
some old fashioned AppleScript, something like:
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
I may be wandering in the weeds because I'm hopped up on cold
medicine, but after some investigation, I find that InDesign CS has
_three_ separate "search" events:
B+event K2 FindB; From Basics suite, only for application and
document
objects
B+event K2TBFindB; From Tables suite, for cell, table, column, and
row
B+event TeXTFindB; For text, character, word, line, text column,
paragraph, text style range, insertion point,
text frame, story, text path
Right, but the codes don't matter. There's no simple way in an
AppleScript dictionary, normally, to indicate what classes a command
can operate on, other than a short explanation, which is pretty
limited. But if you have three search events, and put them, with
appropriate descriptions, in the same suites as the classes they
operate on, rather than one command thrown into a suite that's just
full of commands, all of a sudden you have a more helpful dictionary --
what happens with the different commands underneath doesn't matter to
scripters.
The last one is the one I want, but no matter how I type it, including
pasting in the raw event codes, AppleScript changes it to the first
one (K2 /Find), and it always fails because that event can't search a
story.
Stop dealing in codes and deal in AppleScript. It's English-like.
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?
Now, I know InDesign computes its terminology on the fly from
plug-ins, but the amount of duplicate terminology in this program is
astounding:
No, it's deliberate.
So my first thought is that this must be a horrible, horrible,
horrible bug that renders InDesign scripting mostly useless as you can
never guarantee which event you'll get by typing a command. My second
thought is that this can't be true, because every InDesign CS user who
scripts anything would be screaming bloody murder about it, and that
doesn't seem to be happening.
There's a lot to be said for having second thoughts.
But either way, a simple search for paragraphs that match a given
paragraph style - a core feature of InDesign 2's scripting capability
- doesn't seem to work in InDesign CS because it's using the wrong
event, and I can't figure out how to make it stop doing that, or how
to make it work at all.
So post your script. In English, not code. The codes are a red herring.
Any pointers or explanations are appreciated, including an idea about
whether I'm just daft thinking that six different event codes for
"export" or "select" is a really bad idea.
Anything that makes a dictionary more understandable sounds like a
good idea to me. Others may differ.
--
Shane Stanley <email@hidden>
_______________________________________________
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.