Re: Adding a category to an item in Entourage
Re: Adding a category to an item in Entourage
- Subject: Re: Adding a category to an item in Entourage
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 12 Mar 2004 07:52:32 -0800
On 3/12/04 6:46 AM, "Todd Geist" <email@hidden> wrote:
>
I am trying to add a category to selected items in Entourage. Here is what
>
I have so far.
>
>
-----
>
tell application "Microsoft Entourage"
>
>
set c to the first category whose name is "archived"
>
set theList to the selection
>
>
repeat with theItem in theList
>
tell theItem
>
--set theCategories to category
>
copy c to the end of category
>
end tell
>
end repeat
>
>
end tell
>
----
>
>
Any ideas?
-----
tell application "Microsoft Entourage"
set c to category "archived" -- just do it by name:faster
set theList to the selection
repeat with theItem in theList
tell theItem
set theCategories to its category
copy c to the end of theCategories
set its category to theCategories
end tell
end repeat
end tell
----
1. You were just altering a result (not even a variable). Suppose the
"archived" category is category id 17 and on of the selected contacts has
{category id 3} (e.g. category "Work") as its current category, then:
tell theItem
copy c to the end of category
--> copy c to end of {category id 3} -- for example
--> {category id 3, category id 17}
You still have to set the category property of theItem to that list, and you
haven't done so yet.
2. It may not even have got as far the line above. AppleScript (quite
properly!) gets confused because the class 'category' and the [list type]
property 'category' are called the same and have the same raw code (<<class
cCtg>>). So you always need to specify 'category of theItem' or 'theItem's
category' or, in a tell block to theItem (as in your script) 'its category'
to make it explicit. You must also do the same thing in 'whose' clauses:
every contact whose category contains {category "archived"}
--> {}
every contact where its category contains {category "archived"}
--> [list of 123 contacts, or whatever]
[Note you also need the proper list brackets around the specified category
here: the AppleScript rule is that the same class needs to be on both sides
of the 'contains' and 'is in' operators, and it really does need that here .
Entourage will not do a coercion for you: you'll get an error (Cant't make
<<class cCtg>> id 17 into a vector") if you don't.]
--
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.