Re: OSAX within tells
Re: OSAX within tells
- Subject: Re: OSAX within tells
- From: email@hidden
- Date: Thu, 18 Jan 2001 15:18:18 -0800
>
>>>- Anything that generates an interapplication message (Apple event)
inside a tell block -- including commands for scripting additions -- will
generate an inter-process call, involving the Process Manager. This may
slow down the execution of your script.
I have run numerous tests on several different systems and found, to my
surprise, that many OSAX calls actually go slightly faster within Finder
tells than outside.
>
>>- Some scripting addition commands (such as "display dialog") will cause
user interaction in that application. If that application isn't frontmost,
depending on the behavior of the particular scripting addition, the user
may have to bring that application to the front to see the dialog box; in
other cases, the dialog box will appear in the background (not a Good
Thing).
I have not seen that lately. It's been my expericence that whichever app is
told to display a dialog moves to the front. Even if there are cases where
that does not happen, then I believe it would be better to advise scripters
to activate the app before displaying a dialog otherwise the Applet will
move to the front in order to display the dialog which could also be a
problem, especially if you're running from OSA Menu or another FBA. I
believe Leonard recommends not calling display dialog outside of a tell
block. (At least he used to, he may have fixed that)
>
>>- The possibility for terminology conflicts increases greatly when a
scripting addition's vocabulary is being compared with an application's
vocabulary, as opposed to a scripting addition's vocabulary being compared
with just AppleScript vocabulary.
While this is true, nearly all terminology conflicts are discovered and
identified when compiling and testing..
>
>>>So I'd give the following advice: Be cautious of calling scripting
additions in tell blocks, unless a) you know the behavior of the target
application, b) if that application will already be in the foreground, and
c) if you're only executing the command a small number of times.
My advice would be the mirror image: It's okay to call Scripting Additions
in tell blocks but a)be wary that some OSAX may have have terminology
conflicts with some applications (although this is rare); b)When calling
display dialog and any other OSAX command that requires user interaction
make sure the application is frontmost if it doesn't jump to the front
automatically and c)if you're executing the command a large number of times
(100's or 1,000's) test to see if it executes faster outside the tell.
Imagine this situation: Let's say your working in quark and you are in a
repeat block for every document and a loop for every spread of the current
document, and looping through every page of the current spread and every
text box in the current page and every paragraph in the current text box
and an you're in an if block for testing the first letter of the first word
and you need to get the ascii character and possibly change it and maybe do
a few other OSAX calls. Think of how you would have to clutter up your
script if you had to call every osax outside the application tell! You'd
need a handler for every osax call. Yuk!
Again I agree that there are cases where it's not a good idea or where
known bugs and conflicts exist, but they are easy to identify and avoid.
ES