Re: Category on an Entourage Contact
Re: Category on an Entourage Contact
- Subject: Re: Category on an Entourage Contact
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 15 Oct 2003 19:54:29 -0700
On 10/15/03 6:52 PM, "Irwin Poche" <email@hidden> wrote:
>
I can not figure out how to get the name of a category of a contact.
>
This script...
>
>
>
tell application "Microsoft Entourage"
>
set x to category of contact 568
>
log x
>
name of category x
>
end tell
>
>
>
Gives this result...
>
>
get category of contact 568
>
{category id 12}
>
(*category id 12*)
>
get name of category {category id 12}
>
"Microsoft Entourage got an error: A descriptor type mismatch
>
occurred."
If you look in the Entourage dictionary, you'll see that the 'category'
property of contact (and of event, message, etc. etc.) is a _list_ of
categories. That's because contacts can have multiple categories. It's most
unfortunate that the developers gave the same same 'category' to this
property as to the _class_ 'category': it confuses everybody. they should
have called the property 'category list' or something like that. What you
need to do is this:
tell application "Microsoft Entourage"
set catList to category of contact 568 -- a list
try
set catName to name of (item 1 of catList)
on error -- no category, empty list {}
set catName to "None"
end try
end tell
To be more thorough, and get the names of every category if there's more
than one:
set catNamesList to {}
tell application "Microsoft Entourage"
set catList to category of contact 568 -- a list
repeat with i from 1 to (count catList)
set end of catNamesList to name of (item i of catList)
end repeat
end tell
catNamesList -- could be {} if no category
You can then do something like this if you need the names as text, not a
lost:
set AppleScript's text item delimiters to {", "}
set catNamesText to catNamesList as Unicode text -- or string
set AppleScript's text item delimiters to {""}
catNamesText
--if catNamesText = "" then set catNamesText to "None" -- if you want
end tell
--
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.