Re: "tell application" without starting application?
Re: "tell application" without starting application?
- Subject: Re: "tell application" without starting application?
- From: Duncan Cowan <email@hidden>
- Date: Thu, 28 Nov 2002 14:53:35 +1100
Thanks Paul, I think I see what you mean.
1. I should have moved the iTunes tell block outside of the Finder tell
block and retrieved the process list beforehand and stored it as a variable
(correct term?).
So I could do something like this?
on dothis()
tell application "iTunes"
-- do itunes stuff here.
end tell
end dothis
tell application "Finder"
set allProcs to name of every process
-- do any other finder stuff here
if allProcs contains {"iTunes"} then
my dothis()
else
display dialog "itunes is NOT running"
end if
end tell
2. This is a little clouded - only because I'm not sure where in your script
you made the single item list. Does it occur when you bracketed {"iTunes"} ?
I can see what you mean by the coercion issue as "display dialog allProcs"
tossed up an error.
Nevermind, I'm sure that this will come clear some day soon.
thanks again.
From: Paul Berkowitz <email@hidden>
Date: Wed, 27 Nov 2002 17:39:48 -0800
To: Applescript-Users <email@hidden>
Subject: Re: "tell application" without starting application?
Not quite. 'name of every process' only mans anything inside a Finder tell
block, but you wouldn't want to put that whole if/else block inside a Finder
tell block since it contains a tell block to another application (or would
if you had remembered to include an 'end tell' line). It's not a good idea
to call one app through another - it slows things down and can occasionally
lead to namespace confusion.)So:
tell app "Finder" to set allProcs to name of every process
if allProcs contains {"iTunes"} then
tell app "iTunes"
-- doThis()
end
else
display dialog "iTunes is not running"
end if
---------------
[Note that the 'contains' operator requires the operands on both sides to be
of the same class. Since 'allProcs', or 'name of every process' is a list,
you should makes a single-item list of the list item you're looking for. In
the case of a string within a list of strings, AppleScript will do the
coercion for you, but in other cases it won't. It's better to do it right
every time so you don't forget when it does matter - say with an application
object such as 'process' in a list of processes rather than strings.]
--
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.