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: Brennan <email@hidden>
- Date: Tue, 30 Dec 2008 13:15:37 +0100
On 20/12/08 at 0:48, Chris Page <email@hidden> wrote:
> The clearer your scripts are about intent and the fewer unnecessary
> dependencies they have, the more likely it is we'll be able to improve
> AppleScript for you without breaking your scripts.
I have been following this thread with great interest. It's WONDERFUL to
have someone from Apple here batting the ball back. Thank you Chris Page!
I believe I understand the thrust of Chris's jib rather well. I was
dismayed when I read the earlier posts which implied that tell blocks as
such were a bad thing. I *love* tell blocks, but soon we settled down to
the more thorny issue of scripting additions and dialog boxes.
I think it's fine that Apple recommends particular kinds of practice, in
the light of the scripting addition babel and resource issues, but ahem,
Apple has not been very communicative in this area, and when 'set the
clipboard to' still recommends using a tell block, it's easy to get the
wrong idea. (Besides, maybe I really *do* want to 'set the clipboard to'
the current photoshop selection, and paste it into Graphic Converter).
Specifically I think that we have glossed over the fact that AppleScript
is (at least partly) intended for inter-application communication, i.e.
two or more applications may be involved, so this whole question of which
app should run additions is very much more important than some of the 'it
just works' folks are making out.
I regularly use several utilities for running scripts. Here are some
scenarios.
1) Apple's script menu.
If I run a script from the script menu, I may be targeting a background
app. Quite likely, in fact, at least at some point in the script. For
example, I might want to convert the current Pages document to a .pdf file
and attach it to a new email in Mailsmith. If something goes wrong, -say
the disk is full, just for the sake of argument- I will want to inform the
user with some kind of dialog box.
The question is, which application should notify the user? If the disk is
full, that's a system problem, not Pages or Mailsmith, but if the user is
sitting and working merrily away in Pages, how do I (as a scripter) make
sure that the dialog box emerges from 'the right place' (i.e. so the user
doesn't have to switch app.) Presumably if I make sure the display dialog
is not in a tell app "Pages" or tell app "Mailsmith" block, it will do the
right thing and just display regardless of what ever app is frontmost,
correct?
2) Attachable apps.
OK this once noble feature seems to be rather deprecated (right?), in
favour of Script Menu, but some apps (e.g. BBEdit) still make extensive
use of it. If I do 'open for access' inside a script run from BBEdit's
script menu, am I making an 'unnecessary dependency'?
3) Folder Actions.
I am in (say) Pages. I save a file into a folder with a 'adding items'
event hooked up, but I don't leave the app. Something goes wrong. Who
should notify me? Pages? The Finder? Terminal? Folder Actions Setup?
4) Exotic script runner entry points, such as (shell) osascript, RealBasic
apps, or even (don't laugh) hypercard stacks.
If these scripts display dialogs or open files, how do we avoid
'unnecessary' dependencies?
--
Brennan Young
"Now let's all synchronize our watches and look forward to a better tomorrow."
-Fred Lane
_______________________________________________
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