Re: Entourage: Obtaining items where the item's every category is contained in a list
Re: Entourage: Obtaining items where the item's every category is contained in a list
- Subject: Re: Entourage: Obtaining items where the item's every category is contained in a list
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 19 Jan 2004 09:30:11 -0800
On 1/19/04 8:30 AM, "Patrick Gerzanics" <email@hidden> wrote:
>
Hello. I'm finding it difficult to accomplish something like the following
>
in a single query. Perhaps it is not possible? Regardless, here goes (This
>
was all typed in an e-mail editor, so typos probably exist but should not
>
change the logic I utilize):
You shouldn't send in code you haven't checked in a script error. It's full
of faulty syntax - missing verbs and prepositions. I _think_ I know what
you're trying to do, but I can't be sure. You shouldn't make us try to
figure it out.
You're trying to find all events whose categories (category lists) contain
any one of the three categories below, I think?
>
>
tell application "Microsoft Entourage"
>
set eventList to {}
>
set tempList to every event
>
set categoryList to {category "Personal", category "Family", category
>
"Holiday"} --example category list
>
repeat currEvent in tempList
>
tell currEvent
>
set allFound to true
>
repeat currCategory in category
>
if (currCategory not in categoryList) then
>
set allFound to false
>
end if
>
end repeat
>
end tell
>
if (allFound) then
>
set currEvent to end of eventList
>
end if
>
end repeat
>
end tell
>
>
I'd like to accomplish this in a single query, essentially returning all
>
items where 'every' category of the item is contained in the list. The
>
important thing is that categoryList is of variable length and changes
>
depending on parameters to the script so I can't hard-code it.
'category' property of an event is a list. An AppleScript list.
Unfortunately 'whose' clauses do not work on lists or records. We've been
waiting years for it. So although you can do a single query to find one
category:
>
>
I've tried:
>
>
set eventList to every event where its category is contained in categoryList
>
>
But this only returns events where its 'primary' category is in the
>
categoryList, not every category.
Actually it should only return events which have only one category.
>
>
Any suggestions for how to do this?
>
>
Thanks for any and all assistance!
You need to be a bit more verbose, then you can do it in one command with a
compound 'whose' clause:
set eventList to (every event where its category contains {category
"Personal"} or its category contains {category "Family"} or its category
contains {category "Holiday"}
You do have to spell out the sought-after categories separately. Since event
categories are lists which contain multiple items which can be positioned
anywhere in the list, you have to specify each by name. That still works
amazingly fast: the command above got all 307 of my 495 contacts within
about 8 seconds - it would be much longer in repeat loop (which could be
tightened up a bit from what you sent).
Hope that helps.
--
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.