One feature I have been using on my iPhone is to have an alarm go off one day before an event, and also one hour before the event (“Alert = 1 day before”, “Second alert = 1 hour before”). I can also add more than one alert for an event in iCal.
I have an Applescript that I wrote nearly 10 years ago that sets one alarm:
tell this_event
make new sound alarm at end of sound alarms with properties {trigger interval:trigger, sound name:"2-beeps"}
end tell
where “trigger” is the number of minutes before the event when I want the alarm to sound.
How do I make it set the TWO alerts? Do I simply repeat the first line, with a different value for “trigger”?
Thanks in advance.
Model: MacBook late 2008
AppleScript: 2.2.1
Browser: Safari 536.26.14
Operating System: Mac OS X (10.7)
Hi. Yes, it does involve a repeat loop, as there are multiple alarms per event.
tell application "iCal" to repeat with counter in {{"sosumi", -15}, {"beep", -5}}
tell calendar "Home"'s event 1 to make sound alarm with properties {sound name:counter's item 1, trigger interval:counter's item 2} at end
end repeat
Thanks for the reply.
I don’t really follow your code. Would this work? (with triggerA the number of minutes before the first alert, and triggerB the number of minutes before the second alert?
tell this_event
make new sound alarm at end of sound alarms with properties {trigger interval:triggerA, sound name:"2-beeps"}
make new sound alarm at end of sound alarms with properties {trigger interval:triggerB, sound name:"2-beeps"}
end tell
That’s equivalent to my example, however, “2-beeps” isn’t a standard System sound. I also see no need to variabilize your intervals, unless they get called more than once. The interval is an integer; its positive is in minutes after the event, and the negative is before it.
make new sound alarm at end of sound alarms with properties {trigger interval:-15, sound name:"sosumi"}
make new sound alarm at end of sound alarms with properties {trigger interval:-5, sound name:"frog"}
–edited for typo
I love reading Marc’s code. It makes me feel like I know nothing about AppleScript. Where did you learn to write like that !?!?
Thanks. I learned the basics from (the now very outdated) “Tao of Applescript” and then just started tinkering around. For fan club information, please contact Nigel Garvey. 
Hmmm. Pity about the typo in post #4. 