Re: Tell Blocks Considered Harmful (was Re: open for access)
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