Title: Re: Category of Event via apple script
On 11/30/00 1:57 PM, "Bob Greenblatt" <[EMAIL PROTECTED]> wrote:
> I am trying to get a list of entourage events – ultimately to export to Excel
> and do client billing. However, I am unable to get the category of the event.
> I don’t know if it’s my inexperience (incompetence) with Apple Script, or an
> Entourage problem.
>
> Here is an excerpt of the script I am playing with:
>
>> tell application "Microsoft Entourage" to set xxx to every event ¬
>> whose start time is greater than date "Wednesday, November 1, 2000 12:00:00
>> AM"
>>
>> repeat with eachEvent in xxx
>> tell application "Microsoft Entourage"
>> display dialog category (category of eachEvent)
>> end tell
> end repeat
>
> This produces an error “can’t make category {category id 9} into a string” 9
> is the correct category, but I can’t seem to get hold of either the 9 or the
> category's text. Realizing that each event’s category is a list of
> categories, substituting
> display dialog name of item 1 of category of eachevent
> I get a similar error “cant get name of category of event id 114 into a
> string”
>
> How can I get the text of the category, or even the subscript (category id)?
>
Sorry, Bob, but this is quite muddled in a few regards.
First of all, display dialog only displays text. You are asking for something else: namely the actual category, doubled up. I think you probably want the name property of each category.
Each event’s category (in applescript) is a list of its categories (it can have several). What you want is the name of each one. If you actually want all the category names for each event on a single dialog display, then you have to turn the list of such names into a string (text), which is quite easy. If you use the delimiter between each name as a comma-and-space “, “, it will even look just like a list. Since whose clauses aren’t implemented for applescript lists (believe it or not) you have to use a second repeat loop to get the names.
Then – don’t you want to know which categories go with which event? You’ll need the subject of the event as well then. Also - “None” isn’t actually a category, so I’ve scripted that in (so it doesn’t appear blank). You can change that if you wish.
Finally, before you try this, be ware that “every event” will include every single holiday. Also you shouldn’t have two separate tell blocks for Entourage.
tell application "Microsoft Entourage"
set xxx to every event whose start time is greater than date "Wednesday, November 1, 2000
12:00:00 AM"
set ods to AppleScript's text item delimiters -- the default {""} normally
repeat with eachEvent in xxx
set theCats to category of eachEvent
if theCats = {} then
display dialog (subject of eachEvent) & ": None"
else
set catNames to {}
repeat with aCat in theCats
set end of catNames to name of aCat
end repeat
set AppleScript's text item delimiters to {", "}
set catNames to catNames as string
display dialog (subject of eachEvent) & ": " & catNames
end if
end repeat
set AppleScript's text item delimiters to ods -- restore
end tell
--------------------------
--
Paul Berkowitz
- Category of Event via apple script Bob Greenblatt
- Re: Category of Event via apple script Paul Berkowitz
- Re: Category of Event via apple script Aaron Sills
- Re: Category of Event via apple script Bob Greenblatt
- Re: Category of Event via apple script Paul Berkowitz
- Re: Category of Event via apple script Aaron Sills
