Re: True-False vs True-Error
Re: True-False vs True-Error
- Subject: Re: True-False vs True-Error
- From: Christopher Nebel <email@hidden>
- Date: Mon, 13 Oct 2008 09:47:53 -0700
On Oct 12, 2008, at 8:04 AM, Luther Fuller wrote:
Something I noticed while commenting on "Detecting Applescript and
SKYPE" ...
The Finder's 'exists' command is defined in the Finder's dictionary
as having a Boolean result.
To quote: "→ boolean : true if it exists, false if not"
But this code does not have that behavior ...
tell application "Finder"
exists application file id "com.unknown.something"
end tell
It does return true if it exists, but returns error -10814 if it
does not exist.
A boolean result should return true or false, not true or error.
Easily fixed with a try block, but why should that be necessary?
Is there a bug hiding here?
I wouldn't say it's all that hidden -- this violates the Scripting
Interface Guidelines, and is written up as <radar:5499538>. It's
specific to "exists application file id ..."; the Finder will
correctly return false for other "exists" constructs. Hopefully it
will be fixed at some point, so be sure to write your tests so they
work both ways, as the original one was:
try
exists application file id "com.whatever"
on error
false
end
(Come to think of it, it'd be sort of hard to write it so it
*wouldn't* work if it didn't fail.)
This sort of thing is less necessary in Leopard, since AppleScript
itself understands "application id ..." references, at least in "tell"
blocks. (They regrettably do not respond correctly to "exists";
that's <radar:5499559>.)
--Chris Nebel
AppleScript Engineering
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden