• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Unwinding the containment hierarchy of a reference
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Unwinding the containment hierarchy of a reference
      • From: Sander Tekelenburg <email@hidden>
References: 
 >Unwinding the containment hierarchy of a reference (From: "Scott Babcock" <email@hidden>)
 >Re: Unwinding the containment hierarchy of a reference (From: Christopher Nebel <email@hidden>)
 >Re: Unwinding the containment hierarchy of a reference (From: Michelle Steiner <email@hidden>)
 >Re: Unwinding the containment hierarchy of a reference (From: Chris Espinosa <email@hidden>)

  • Prev by Date: Re: [OT] Re: Smile and FruitMenu
  • Next by Date: Re: [OT] Re: Smile and FruitMenu
  • Previous by thread: Re: Unwinding the containment hierarchy of a reference
  • Next by thread: Re: Unwinding the containment hierarchy of a reference
  • Index(es):
    • Date
    • Thread