On Dec 17, 2008, at 01:13, Chris Page wrote: 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
Chris, first thank you for all the attention, it has been very instructive. Second, apparently you've touched something very sensitive. Some of the OSAX commands will normally be acted outside tell blocks. I assume most of the scripters do that naturally. However, some of the commands are used much more for controlling and debugging. display dialog and display alerts are useful as debugging tool and as user interaction tools, and in fact they should be overhauled altogether. Most of the points you make would be unnecessary if we had the option to make the modal level of the commands as options. E.g. display dialog "please wait while we compute " giving up after 10 modal no display dialog "please wait while we compute " giving up after 10 modal document display dialog "please wait while we compute " giving up after 10 modal application display dialog "please wait while we compute " giving up after 10 modal system
Actually having the dialog pop up in front of all the apps so that we can always find it would be a great improvement. I use spaces, and Safari and Script Editor (or Smile) are in different spaces. Try this: --- tell application "Safari" to activate delay 1 tell application "System Events" to display alert "Wait" -- One might not find the dialog and the script will be hanging there waiting.
The workaround is: ___ tell application "Safari" to activate delay 1 tell application "SystemUIServer" to display alert "Wait" ___
But how would people know?
Again, thank you for your time and patience....
Deivy
|