Re: Unwinding the containment hierarchy of a reference
Re: Unwinding the containment hierarchy of a reference
- Subject: Re: Unwinding the containment hierarchy of a reference
- From: Michelle Steiner <email@hidden>
- Date: Tue, 7 Dec 2004 18:50:14 -0700
On Dec 7, 2004, at 6:22 PM, Chris Espinosa wrote:
Some functions give you an object specifier, a "reference", to an
object in the app. And you may want to know what the containment chain
— the specific containment chain displayed in AppleScript — for that
object is, but the object may not have a property for its container.
The object specifier knows the containment chain. That's why
AppleScript can display it the way it does, e.g. word 1 of paragraph 2
of document "foo". So AppleScript has, at runtime, its grubby little
mitts on all the information he wants.
OK, that much I already knew.
There's just no built-in function to return, say, a list of objects
(e.g. {word 1 of paragraph 2 of document "foo", paragraph 2 of
document "foo", document "foo", application "TextEdit"})
There's where I'm failing to understand. To get that list, either one
would need to parse the object specifier--but since the object
specifier is already known, why--or one would need to start somewhere
and work backwards.
Specifying a word to work backwards wouldn't work because words are
not unique, so one could have many instances of, for example "Michelle"
to try to work backwards from.
But in some instances, it can be done, if the top of the chain is
known. For instance:
tell application "Mail"
the selection
end tell
--> {message 1 of mailbox "Applescript" of application "Mail"}
One could write a scripting addition that takes an object specifier
and returns a list. Would take me a couple hours.
Would it really take that long? Here's a specific case, in
Applescript. I realize that it's not a general solution, but it might
point the way.
tell application "Mail"
try
display dialog (message 1 of mailbox "Applescript" of application
"Mail")
on error msg
set AppleScript's text item delimiters to "make "
set msg to text item 2 of msg
set AppleScript's text item delimiters to "into"
set msg to text item 1 of msg
set AppleScript's text item delimiters to " of "
set msg to text items of msg & "Application \"mail\""
set AppleScript's text item delimiters to ""
end try
end tell
msg
-- Michelle
--
Tubal Litigation: Suing because of a misconception
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden