Re: What are the elements listed in a dictionary?
Re: What are the elements listed in a dictionary?
- Subject: Re: What are the elements listed in a dictionary?
- From: Brennan <email@hidden>
- Date: Sun, 23 Mar 2003 11:12:52 +0100
On Sat, 22 Mar 2003 14:00:24 -0600, Jeffrey Mattox <email@hidden> wrote:
>
Thanks for the comments, but I'm still confused. Perhaps some
>
specificity to my original question would help:
>
>
A text field also has elements such as "movie view" and
>
"progress indicator." What does this mean, and how can I
>
use this information?
Other people have suggested reasons why a text field would have these
elements, but I haven't seen a clear explanation of how you would use this
information.
Strictly speaking, elements are similar to properties, but they are properties
with structure, and are almost always described in further detail under their
own heading. One good example which has been suggested is mailbox and message.
In order to know what you can do with an object of type 'message', you look at
the 'message' class, but I think you understand this already.
What's important is that the elements describe the HIERARCHY of objects. In
other words it's meaningless to talk about 'message 3' without first referring
to its container object, which we know to be a mailbox.
-- meaningless (probably causing an error)...
tell application "myScriptableMailClient"
tell message 1
-- something
end tell
end tell
-- meaningful (correct hierarchy)...
tell application "myScriptableMailClient"
tell mailbox "spam"
tell message 1
-- something
end tell
end tell
end tell
The art of deciphering dictionaries is to start with the application object
and look at what elements it contains. Usually you have an inkling which
object you want to manipulate, so if you see it listed there, you build the
'tell path' to the object by seeing which elements contain the elements which
ultimately contain the object you want.
The way this is shown in the dictionary is (I think we all agree) not
particularly conducive to grasping the hierarchy concept (actually, it sucks),
and this is at least partly responsible for the slow adoption of Applescript
by end users and developers alike. We still commonly see dictionaries that
don't have an application object or any hierchy at all, and we still see
scripts generated by 'recording' which make repeated nested references from
the top level of the hierarchy instead of wrapping things up more sensibly in
nice tell blocks.
'Script Debugger' does the right thing by presenting a graphical view of the
'containment hierarchy' of all the elements provided by any dictionary. If
you're still confused after reading all this stuff, see if you can get a demo
of that program, and examine these diagrams. Even if you can't justify the
investment in 'Script Debugger' (I can't - especially with Smile about - but I
do recognise it as excellent value), being able to see these diagrams might
just make things click into place.
Good luck
Brennan
_______________________________________________
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.