Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

martijnpolman

macrumors newbie
Original poster
Nov 25, 2008
1
0
Hello this is my first post, I'm completely new to applescript. I wanted to make a script that will make my mac speak when the next bus will arrive at my home. I have imported my bus schedule into iCal. I made the following script:

tell application "iCal"
set theEvents to every event of calendar "Buslijn 5" whose start date is greater than (current date)
set theNextbus to start date of item 1 of theEvents
repeat with i in theEvents
if start date of i ≤ theNextbus then
set theNextbus to start date of i
end if
end repeat
say "the next bus will arrive at " & theNextbus
end tell

This will end up telling me the first bus to leave on 29th november 2008, not the next bus (usually 10-25 minutes away)

What do I need to do in order to get applescript to sort the events so that I will get the start date of the first upcoming event?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.