Re: Bizzare osascript/CodeWarrior behavior
Re: Bizzare osascript/CodeWarrior behavior
- Subject: Re: Bizzare osascript/CodeWarrior behavior
- From: Chris Espinosa <email@hidden>
- Date: Fri, 25 Jun 2004 10:16:50 -0700
On Jun 25, 2004, at 9:10 AM, Wade Williams wrote:
I'm trying to implement the following script through osascript:
[dreamline:tk/app/macintosh] wade% osascript
set x to false
tell application "Finder" to set x to the name of every process
contains "CodeWarrior IDE"
if x is equal to true then
tell application "CodeWarrior IDE" to quit
end if
^D
What's bizarre is that as soon as I hit Control-D to terminate input,
CodeWarrior launches and then quits (which is exactly the behavior I'm
trying to avoid).
If I try another application like TextEdit, it works fine. If I try
the same script from ScriptDebugger, it works fine (although one time
it did do the behavior of launching and quitting when it compiled the
script)
So, it seems like it's some sort of bug in CW's AppleScript handling.
I'm just curious to see if anyone has any thoughts on what might be
going on?
BTW, I also tried:
tell application "Finder" to set x to the name of every process
contains "CodeWarrior IDE"
if x contains "CodeWarrior IDE" then
tell application "CodeWarrior IDE" to quit
end if
What's happening here is that 'application "CodeWarrior IDE"' is an
object reference, and to compile it to an object, AppleScript goes
through the normal motions -- which includes getting the app's
dictionary. Since CodeWarrior has dynamic terminology, it has to be
launched to get the dictionary (unlike TextEdit, as you discovered.)
Script Editor and ScriptDebugger separate the compilation and execution
phases, so you don't notice it as much there. osascript always
compiles its input, so it always happens there.
The solution is to create the object when the script is run, not when
it's compiled:
set CodeWarrior to "CodeWarrior IDE"
tell application "Finder" to set x to the name of every process
if x contains CodeWarrior then
tell application CodeWarrior to quit
end if
Chris
_______________________________________________
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.