Skip navigation

Applescript and iCal

561 Views 5 Replies Latest reply: Jul 30, 2013 8:39 AM by glu000 RSS
glu000 Calculating status...
Currently Being Moderated
Jul 24, 2013 5:21 PM

Hi,

 

I'm new to Applescript and have a litte problem with iCal. In my script I want to get a list of all summaries of a iCal calendar. But for some reasons I want to set all events to a variable first and get the summary of all events from this variable (and not directly from iCal). I tried it in this way:

 

 

 

tell application "Calendar"

 

       

          set sumList to summary of events of calendar "Sync"   -- works fine, result is a list of all summaries

 

          set calList to events of calendar "Sync"                         -- works fine, result is a list of claendar events

 

          set sumList1 to get summary of every item of calList -- doesn't work (error 1728)

 

end tell

 


Any ideas why the 3rd line doesn't work?

applescript, OS X Mountain Lion (10.8.4)
  • Frank Caggiano Level 7 Level 7 (22,760 points)
    Currently Being Moderated
    Jul 25, 2013 6:13 AM (in response to glu000)

    Every item of calList is still a list and when you try to apply summary to it Applescript doesn;t know what to do (basically what a 1728 error is) If you put the statement in a try block and catch the error this is what you see

     

    Screen Shot 2013-07-25 at 09.09.21.png

    Notice it is telling you it can;t get the summary of a list.

     

    Try this instead

    set sumList to {}

              repeat with calEvent in calList

                        copy summary of calEvent to end of sumList

    end repeat

     

    By intenerating over each element in the list (a cal event) you can then apply summary to it.

  • Bernard Harte Level 4 Level 4 (3,025 points)
    Currently Being Moderated
    Jul 30, 2013 6:59 AM (in response to glu000)

    You can get more than one property at a time (in the same loop).  For example, the following, will give you a list of lists (with a sublist for each event which contains the summary, start date, end date, uid).  However, if you explain what you are trying to do, there may be a better way.

     

    tell application "Calendar"

              set calList to events of calendar "XX"

     

              set propList to {}

              repeat with calEvent in calList

          copy {summary, start date, end date, uid} of calEvent to end of propList

      end repeat

     

    end tell

    propList

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.