Application tell nesting (was: Damn send button/Wind chill)
Application tell nesting (was: Damn send button/Wind chill)
- Subject: Application tell nesting (was: Damn send button/Wind chill)
- From: David Lloyd <email@hidden>
- Date: Sun, 03 Mar 2002 18:51:27 +1100
Paul B:
>
You should avoid putting one tell block inside another, which is similarly
>
wasteful, sluggish and occasionally worse, and avoid putting commands that
>
go to AppleScript or scripting additions like Standard Additions into a
>
Finder or any other application tell block, unless there's a good reason
>
(such as needing to work with some application objects, when of course it
>
would be necessary.)
Perhaps Paul meant putting a tell *application* block into another tell
*application* block is bad...but it's correct (or probably essential) to put
say a tell document block inside a tell application block... (Sorry to be
pedantic, many newbies may have be led sideways here.)
With regard to wrapping scripts within tell blocks, it is better to avoid
this to minimize risk of terminology conflict, e.g:
(note I currently have GTQ Sort osax installed)
This script runs:
copy (choose folder) to theFolder
set theItems to list folder theFolder
sort theItems
...while this script fails:
copy (choose folder) to theFolder
set theItems to list folder theFolder
tell application "Finder"
sort theItems
end tell
It fails because 'sort' is both an osax and a Finder word.
So it's not clever to nest in this case.
Then Shane S. asked, after providing an example:
>
...That suggest to me that nesting tells to applications is no problem at all.
...if I take my above example, and dare to nest application tells:
copy (choose folder) to theFolder
set theItems to list folder theFolder
tell application "Finder"
tell application "QuarkXPress 4.11"
sort theItems
end tell
end tell
...well now, this script runs OK.
This suggests that application nesting shelters the script within from any
terminology outside of it.
Therefore I wonder if it *that* wrong to incorporate such nesting?
Perhaps it's more a good thing rather than otherwise?
While scripting Facespan, I found it essential in some cases to do such
application nesting, even incorporate a 'false nesting' to shelter my script
from some of Facespan's own terminology.
(However, sometimes a "tell me to do [some script]" would do.)
Best regards,
David Lloyd
---------------------------------
email: email@hidden
web:
http://www.kanzu.com
---------------------------------
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.