I'm trying to write an AppleScript to query iCal and find all the events I've got for a given date, in any calendar.
I started by writing a simple script that does something simple with every event in a given calendar:
tell application "iCal"
tell calendar "Reuniones"
set the_events to every event
repeat with an_event in the_events
-- do something with every event
set value to summary of an_event
end repeat
end tell
end tell
However, this simple script is taken a lot of time to execute (a few seconds), even if I'm not doing anything complex inside the loop. I'm afraid that the real script will really take a lot of time to execute.
I'm not very familiar with Applescript, and thus I imagine I'm doing something silly that has severe performance implications.
Can anybody explain me why this takes that much to execute? Can anybody suggest something to improve my code? I'm now going to start checking the date of the event, with a condition in the loop. I suspect there must be a way to search for events with a date (like the Automator action does), but I haven't been able to find a "native" way to do so ....
EDIT: I'm using Mac OS X Tiger (10.4). It is possible that newer versions of iCal have improved the library of operations available.