• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting info back from iCal: missing values ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Getting info back from iCal: missing values ?
      • From: pete boardman <email@hidden>
    • Re: Getting info back from iCal: missing values ?
      • From: Paul Berkowitz <email@hidden>
References: 
 >Getting info back from iCal: missing values ? (From: Jay Louvion <email@hidden>)

  • Prev by Date: Re: How to deal with Asynchronous Finder operations
  • Next by Date: Re: Getting info back from iCal: missing values ?
  • Previous by thread: Re: Getting info back from iCal: missing values ?
  • Next by thread: Re: Getting info back from iCal: missing values ?
  • Index(es):
    • Date
    • Thread