Re: Addressing an app that may or may not exists (without alerting user)
Re: Addressing an app that may or may not exists (without alerting user)
- Subject: Re: Addressing an app that may or may not exists (without alerting user)
- From: Matt Neuburg <email@hidden>
- Date: Wed, 01 Mar 2006 09:16:11 -0800
- Thread-topic: Addressing an app that may or may not exists (without alerting user)
On Mon, 27 Feb 2006 09:03:22 -0800, "Sean P. Kane" <email@hidden>
said:
>I have added support for Growl into my script and would like it simply
>to be used if the user happens to have it installed. I have it in a
>try block that does nothing on error. However the problem I have is
>that it the system asks to locate the GrowlHelper application I am
>addressing when it can't find it instead of simply failing silently.
>Is there a way to write this so that it will not ever ask the user
>where this application is?
This situation is covered in detail in the "Missing External Referents"
section of Chapter 3 of the new edition of my book. First of all, you can't
prevent this at all if the user is going to open the script for editing,
because that's decompilation and requires the application's dictionary.
Otherwise, if you don't want this to happen, you must prevent the path of
execution from encountering the "tell GrowlHelper" block at all. However,
there's a trick (see p. 295): wrap the whole thing in a terms block and,
within it, refer to the application using a string variable, not a literal:
try
using terms from application "whatever"
set s to "whatever"
tell application s
display dialog "howdy"
end tell
end using terms from
on error
display dialog "heh heh"
end try
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden