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: Bill Cheeseman <email@hidden>
- Date: Wed, 03 Dec 2008 06:05:19 -0500
- Thread-topic: Tell Blocks Considered Harmful (was Re: open for access)
on 2008-12-02 11:51 PM, Chris Page at email@hidden wrote:
> Although judicious use of tell blocks to address specific objects can
> make code clearer when you're performing several consecutive
> operations on the same object, most of the time they're unnecessary,
> and they can cause problems when inside "tell application" blocks.
For the sake of future scripters searching the mailing list archives, I
think it might be helpful to clarify this a little by making the context
explicit. I haven't been following this thread closely, so this may already
be obvious from previous messages in the thread.
I believe I am correct in understanding that your remarks are limited to
nested 'tell' blocks addressed to applications or application processes that
are different from the script's primary application target. I base this on
your further statement:
> You should favor individual "tell ... to" statements for events that
> must be sent to other applications and use "using terms from" when all
> you need is the terminology without altering the current target
> ("it").
In general, my understanding has always been that breaking an ordinary
AppleScript script into multiple 'tell' blocks directed to objects within
the current target application is perfectly acceptable and does not impose
any performance constraints. It certainly makes code easier to read. For
example, this snippet should be OK:
tell application "Finder"
tell window 1
-- multiple statements affecting Finder window 1
end tell
end tell
But you are saying that this snippet is NOT OK, at least in principle:
tell application "TextEdit"
tell application "Finder"
tell window 1
-- multiple statements affecting Finder window 1
end tell
end tell
end tell
Right?
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com
PreFab Software - www.prefabsoftware.com
_______________________________________________
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