• 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: Tell Blocks Considered Harmful (was Re: open for access)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tell Blocks Considered Harmful (was Re: open for access)


  • Subject: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • From: Chris Page <email@hidden>
  • Date: Tue, 16 Dec 2008 22:13:57 -0800

On Dec 16, 2008, at 9:18 PM, Rick Gordon wrote:

Is the code below interpreted as nested, or does the "root" variable allow it to bypass. It does what I really want, which is that the dialog appears in the current frontmost application.

set root to me
tell application "Adobe InDesign CS3"
	tell active document
		tell root to display dialog "Boo!"
	end tell
end tell


That works, but the variable “root” is extraneous. You can just say “tell me to display dialog "Boo!"”. “me” always refers to the surrounding script.

Or you can be more explicit:

  tell application "Adobe InDesign CS3"
  	tell active document
  		tell the current application to display dialog "Boo!"
  	end tell
  end tell

“current application” always means the application running the script.

I used “me” just for brevity, so people don't balk quite so much when I tell them to add “tell ... to ...” in front of scripting addition commands inside tell blocks, but it's less explicit and specific than “current application”.

For example

  on display dialog message
    say message
  end

  tell application "Finder"
    tell desktop
      tell me to display dialog "Hi!"
    end tell
  end tell

“tell me to ...” sends the command to the script first, and since we've defined a “display dialog” handler, that handler is called and the message is spoken instead of displayed in a dialog.

But if we write “tell current application to display dialog "Hi!"” it sends the command directly to the current application, which displays the dialog.

--
Chris Page

  The other, other AppleScript Chris

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Tell Blocks Considered Harmful (was Re: open for access)
      • From: Deivy Marck Petrescu <email@hidden>
References: 
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Shane Stanley <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Chris Page <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Ed Stockly <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Chris Page <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Rick Gordon <email@hidden>)
 >Re: Tell Blocks Considered Harmful (was Re: open for access) (From: Rick Gordon <email@hidden>)

  • Prev by Date: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • Next by Date: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • Previous by thread: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • Next by thread: Re: Tell Blocks Considered Harmful (was Re: open for access)
  • Index(es):
    • Date
    • Thread