Re: setting categories in Entourage X
Re: setting categories in Entourage X
- Subject: Re: setting categories in Entourage X
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 25 Jun 2002 00:20:40 -0700
On 6/24/02 11:44 PM, "garrett" <email@hidden> wrote:
>
using Entourage X SR1:
>
>
the goal:
>
>
take an existing object in Entourage (like a contact), read its categories,
>
then create a new note based on some of the items in the contact.
>
>
>
the script:
>
>
>
>
property theCategory_SerialNumber_Name : "info_Serial Numbers"
>
>
tell application "Microsoft Entourage"
>
set theContact to selection
>
set theContact to item 1 of theContact --set the variable to the first
>
item in the list
>
set categoryList to category of theContact --get the contacts categories
>
>
set theCategories to {}
>
repeat with aCategory in categoryList
>
set end of theCategories to name of aCategory
>
end repeat
>
set theCategories to theCategories & theCategory_SerialNumber_Name
theCategories is a list, so you should actually write:
set end of theCategories to theCategory_SerialNumber_Name
which is best. or else concatenate two lists (more memory-wasting):
set theCategories to (theCategories & {theCategory_SerialNumber_Name})
What you do when you do do it your way above is force a coercion. hat won't
work in all circumstances:
set theCategories to theCategory_SerialNumber_Name & theCategories
--> [you'll get a string that runs everything together.]
But that's not the problem here.
>
>
try
>
set NewNote to make new note with properties
>
{category:theCategories}
!!! But theCategories is a list of STRINGS (names) , not actual categories.
Of course that doesn't work.
First of all, do you actually have a category with
theCategory_SerialNumber_Name as its name, or do you have to create one
first? Let's assume it's actually a name (string) like the others.
In that case there was no need for you to do that repeat loop to get the
names of the categories. Just
set categoryList to category of theContact --get the contacts categories
set end of categoryList to category theCategory_SerialNumber_Name
set category of theContact to categoryList
Or:
set categoryList to category of theContact --get the contacts categories
set category of theContact to (categoryList & {category
theCategory_SerialNumber_Name}
If that awfully cumbersome theCategory_SerialNumber_Name is actually a
category and not a name then you won't need 'category' in front of it.
Garrett, other people have already suggested that you should read up on
basic AppleScript in the AppleScript Language Guide. Or start with the Danny
Goodman AppleScript Handbook, which explains things very clearly. You keep
stumbling on misunderstandings of the AppleScript language, You have a
pretty good grasp of the Entourage dictionary - what you're missing is the
knowledge of correct AppleScript syntax - how to use lists, keeping objects
and names of objects separate, etc. AppleScript only "looks like" English -
it has its own rules which aren't always obvious.
>
open NewNote
>
link NewNote to theContact
>
>
on error errMsg number errNum
>
display dialog "Application got an error " & errNum & return &
>
return & errMsg
>
end try
>
end tell
>
>
>
When it comes time to make the new note, I get an error: Microsoft Entourage
>
got an error: Expected a reference. Error -1727.
>
>
it has to to with "with properties {category:theCategories}"
>
>
if I remove that it works. an inspection of the var theCategories yields:
>
>
{"Computer_Software_Utilities", "Computer", "Computer_Sales", "info_Serial
>
Numbers"}
>
>
all which are valid categories...
No they're not. They're NAMES of categories.
>
>
any ideas?
I keep giving you ideas, on two mailing lists and a newsgroup, but you don't
often acknowledge them. Should I continue to do so, or wait for someone else
to answer?
>
--
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.