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: kai <email@hidden>
- Date: Mon, 13 Mar 2006 22:15:26 +0000
On Mar 13, 2006, at 9:50 AM, Sean P. Kane wrote:
In the end I could not get any of the suggested methods to work.
Even if I had logic that should have missed the tell application
block completely if they did not have Growl installed, it still
seemed to ask for it (and I tried 4 or five methods), so for now, I
just made it a requirement, instead of an option. This is broken
functionality in my opinion. There should be a proper way of
handling this situation. I can't imagine that it is all that unusual.
The advice given by Matt N. should actually work, Sean - depending on
exactly what you're trying to do.
Matt's message covered a number of points - so perhaps I can pick
through some of them in an effort to help you determine whether
functionality really is broken.
Let's take an example like this:
---------------
set growlHelper to "GrowlHelperApp"
tell application "System Events" to set ¬
useGrowl to exists process growlHelper
if useGrowl then
using terms from application "GrowlHelperApp"
tell application growlHelper
(* Growl routine here*)
end tell
end using terms from
end if
---------------
As mentioned, we can avoid a "Where is x?" dialog by using a tell
statement that refers to the target application as a variable, rather
than a literal.
However, since any application-specific terms will now not compile
correctly (if at all) as executable code, we need something more. The
simplest fix is to wrap the tell block in a 'using terms from block'
- which *does* need to refer to the target literally (to access its
AS dictionary). So, to compile the script, the relevant application
must be present.
If we then save the script as an applet, it should run as intended
(without asking for the location of the application, should it be
unavailable). Saving as a compiled script and running from the Script
Menu should work similarly.
However, if we then try to reopen the script in Script Editor, then
the saved raw code would need to be decompiled, so that it may be
displayed in a window as human-readable terms. If this is attempted
without the application present, we'll get the old "Where is x?"
dialog again.
Are any of these issues at play in your situation - or are we looking
at some other behaviour/circumstance?
---
kai
_______________________________________________
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