Re: Getting info back from iCal: missing values ?
Re: Getting info back from iCal: missing values ?
- Subject: Re: Getting info back from iCal: missing values ?
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 20 Sep 2005 07:59:51 -0700
- Thread-topic: Getting info back from iCal: missing values ?
Title: Re: Getting info back from iCal: missing values ?
On 9/20/05 2:22 AM, "Jay Louvion" <email@hidden> wrote:
Has anyone tried this ?
set today to (current date)
tell application "iCal"
set TodaysEvents to get (every event of every calendar whose start date is today)
end tell
I’m possibly getting it quite wrong, but what does that return to you people ?
You're getting it wrong. As written, that's looking first for calendars whose start date is 'today'. Calendars don't have start dates, so that's going to error. Well, being the freaky Cocoa app that iCal is, instead of an error, you get a list of 'missing value' - as many as you have calendars.
Not to mention that your variable 'today' is fixed at this very moment in time – to the second. Is that really what you're looking for, rather than events which start some time between midnight and 23:59:59?
You can't avoid a repeat loop through the calendars – one of the liabilities of an object model that puts events as elements of separate calendars rather than the one you may be used to from Entourage (which you script, I think) where category is simply a property of event so you can search the whole 'calendar' (actually, application in the current version of Entourage) at once.
Try this:
set now to (current date)
copy now to midnight
set time of midnight to 0
set tomorrow to midnight + (1 * days)
tell application "iCal"
set TodaysEvents to {}
set allCals to every calendar
repeat with aCalendar in allCals
set thisCalsEvents to get (every event of aCalendar whose start date > midnight and start date < tomorrow)
set TodaysEvents to TodaysEvents & thisCalsEvents
end repeat
TodaysEvents
end tell
It's extremely fast too, in spite of the repeat loop.
--
Paul Berkowitz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden