Re: Funny (obscure) 'using terms from' usage
Re: Funny (obscure) 'using terms from' usage
- Subject: Re: Funny (obscure) 'using terms from' usage
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 29 Sep 2002 08:54:05 -0700
On 9/29/02 8:19 AM, "Harald E Brandt" <email@hidden> wrote:
>
As an example, take this routine for using AppleScript Output, which
>
my installer places in the users scripting additions folder. To make
>
its usage easy in many places, we place it in a handler thus:
>
>
property ASOpath : ""
>
set ASOpath to ((path to scripting additions as string) & "AppleScript
>
Output")
>
>
ASO("message", 1) --Somewhere in the script app
>
>
on ASO(infoText, cmd) --cmd is 0 for no activation, 1 for making it active
>
using terms from application "AppleScript Output"
>
tell application ASOpath
>
if cmd is 1 then activate
>
if infoText is not "" then display infoText as string
>
end tell
>
end using terms from
>
end ASO
>
>
The above thing, saved as run-only, will NOT work in OS 8.6 without
>
the dreadful dialog "where is..."!
>
>
However, if the routine above is replace by this:
>
>
using terms from application "AppleScript Output"
>
on ASO(infoText, cmd) --cmd is 0 for no activation, 1 for making it active
>
tell application ASOpath
>
if cmd is 1 then activate
>
if infoText is not "" then display infoText as string
>
end tell
>
end ASO
>
end using terms from
>
>
Then the thing works whithout getting the dreadful dialog!?
>
But to me, it looks ridiculous to have 'using terms' outside the handler!
>
Is that really right?
>
>
And why is this behavior?
>
>
Also, what do I do if I need a large handler with several such things?
>
I can't really enclose big handlers with a bunch of 'using terms from', can I?
What if you put the 'using terms from' around the _call_ to the handler in
the main script (or calling handler)? Does that help? E.g.
using terms from application "AppleScript Output"
my ASO(infoText, cmd)
end using terms from
on ASO(infoText, cmd) --cmd is 0 for no activation, 1 for making it active
tell application ASOpath
if cmd is 1 then activate
if infoText is not "" then display infoText as string
end tell
end ASO
I grant that the way you demonstrate looks odd. I'd guess that 'using terms
from' only works with global variables (top-level variables are effectively
global unless declared as local). So the other thing you could try would be
declaring ASOpath as global at the top of your script, and then putting
'using terms from' inside the handler. It's worth a try, anyway (untested,
as is the other suggestion).
--
Paul Berkowitz
_______________________________________________
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.