Re: App switcher in OS 9
Re: App switcher in OS 9
- Subject: Re: App switcher in OS 9
- From: Christopher Nebel <email@hidden>
- Date: Mon, 30 Apr 2001 11:29:54 -0700
On Monday, April 30, 2001, at 01:45 AM, Jan Pieter Kunst wrote:
In the short time I've been working with Applescript, I already found
that
if properties seem out of reach, it often works to set a variable to the
value of the property and reference that variable instead of the
property
itself. I'm sure someone else can explain the deeper reasons behind
this.
One explanation, coming up! First off, things that work and things that
don't:
tell application "Application Switcher"
get item 1 of position of palette -- no dice.
set x to position of palette
item 1 of x -- this works...
get item 1 of ((position of palette) as list) -- as does this...
get item 1 of (get position of palette) -- or this.
end
The problem has to do with how AppleScript sends "get data" commands to
applications and how applications handle them. If you watch the event
log for the first form (the one that doesn't work), you'll notice that
it says "get item 1 of position of palette", but the others all just say
"get position of palette".
In general, applications don't define accessors for AppleScript-defined
properties and elements. (Try asking the Finder for character 1 of the
name of the startup disk. Same issue.) Therefore, if you try to ask
them for the sub-bit in one shot, it won't work -- AppleScript assumes
that the application will take care of everything, and it doesn't.
Instead, you have to ask for the smallest bit that the application knows
about (in this case, the position of the palette), and then ask
AppleScript for the sub-bit as two steps. You can do the two steps in
one statement by using an explicit "get" or an AppleScript coercion, but
it amounts to the same thing.
This is all rather counter-intuitive and irritating, of course, but
unfortunately, solving it is hard and would probably require cooperation
from applications. It's on my list, but a ways down.
--Chris Nebel
AppleScript Engineering