Re: Using tell application "name" where the name comes from GUI Script...
Re: Using tell application "name" where the name comes from GUI Script...
- Subject: Re: Using tell application "name" where the name comes from GUI Script...
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 17 Apr 2003 11:52:11 -0400
on 03-04-17 9:59 AM, Kevin Bohan at email@hidden wrote:
>
>> Any idea how I can get this to distinguish creator codes based on case?
>
>
>
> This looks like one of System Events many bugs.
>
>
>
>
Interestingly I get a similar issue if do the following which doesn't even
>
use System Events...
>
>
property theExceptions : {"sdev", "PNfx", "PRLN", "tims", "osaM"}
>
>
tell the application "Finder" to ,
>
get (the name of every application process ,
>
whose creator type is not in theExceptions) as list
>
>
So it looks like it not an issue with System Events, might be something to
>
do with the considering clause not working with a whose clause perhaps?
The Finder hands 'process' stuff like this off to System Events for
execution, behind your back. So the fact that this script, when addressed to
the Finder, behaves the same as when it is addressed to System Events is to
be expected.
Nevertheless, you're correct that the issue is not due to System Events.
Your speculation that the considering clause is not working with a whose
clause is right on the money.
What the youngsters [ ;-) ] on the list are forgetting is that the
'considering case' statement is very precisely defined in the AppleScript
Language Guide. It works only in string comparisons. The filter reference
form (a/k/a "whose clause") does not involve a comparison, but a filter.
That is, the "is" or "=" or whatever that forms part of a whose clause,
although it looks an awful lot like a comparison or containment operator, is
actually what you might call a "filter" operator. The Glossary in the ASLG
defines "filter" as "a phrase, added to a reference to a system or
application object, that specifies elements in a container that match one or
more conditions" (the "condition" to be "matched" being designated in "a
Boolean expression," to use the words in the filter reference form section
of the ASLG). This is quite different from the definition of "operator": "an
AppleScript language element ... used in an expression to derive a value
from another value or pair of values" (the "value" derived from a comparison
operator acting on a pair of values is the Boolean value 'true' or 'false').
I recognize that I am rationalizing what is, at best, a very fine
distinction, and that we might all be much happier if 'considering case' and
similar statements did work in whose clauses. Nevertheless, it has always
been like this.
Here is another fine distinction to be drawn: The ASLG says that the
'considering case' statement only works with string "comparisons;" it
carefully avoids saying it only works with string "comparison operators."
Table 6-1 of the ASLG describes some operators as "comparison operators" and
others as "containment operators". In fact, however, the 'considering case'
statement works with containment operators such as 'is in' as well as
comparison operators like '=', both of which are apparently considered
"comparisons" for purposes of the rules applying to the 'considering case'
statement.
Consider this hopefully instructive snippet:
tell application "System Events"
creator type of process "Dock" --> "dock"
creator type of process "Dock" = "dock" --> true
creator type of process "Dock" = "DOCK" --> true
creator type of process "Dock" is in {"dock"} --> true
creator type of process "Dock" is in {"DOCK"} --> true
considering case
creator type of process "Dock" --> "dock"
creator type of process "Dock" = "dock" --> true
creator type of process "Dock" = "DOCK" --> false
creator type of process "Dock" is in {"dock"} --> true
creator type of process "Dock" is in {"DOCK"} --> false
creator type of every process whose creator type = "DOCK"
--> {"dock"}
creator type of every process whose creator type = "DOCK"
result = {"dock"} --> true
creator type of every process whose creator type = "DOCK"
result = {"DOCK"} --> false
creator type of every process whose creator type = "DOCK"
result is in {"dock"} --> true
creator type of every process whose creator type = "DOCK"
result is in {"DOCK"} --> false
end considering
end tell
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
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.