osx - Multiple Event Alarms with Calendar and Applescript? -


i'm working on applescript generate , add large number of events calendar many of need multiple alarms: "default" alarm @ 9 , second alarm @ time stored in variable. however, when run alarms created inconsistent: 1 alarm, other, both.

here's sub handles 100% of interaction calendar , test case.

on makecalendarevent {eventtitle, eventstart, eventduration, eventdescription, eventurl, alarmtime, setdefaultalarm} --duration (in hours, 0= instantaneous, -1= day) --alarmtime (date or false) --defaultalarm 9am (coded here moment, may move parameter var block @ point)  if eventduration = -1     set isallday true     set eventduration 0 else     set isallday false end if  tell application "calendar"     tell calendar "test"         set newevent make new event @ end properties {summary:eventtitle, start date:eventstart, end date:(eventstart + (eventduration * hours)), allday event:isallday, description:eventdescription, url:eventurl}         if alarmtime not false             tell newevent                 set alarm1 make new sound alarm @ end of sound alarms properties {trigger date:alarmtime}             end tell         end if          if setdefaultalarm true             tell newevent                 set alarm2 make new sound alarm @ end of sound alarms properties {trigger date:(date "09:00 am" of eventstart)}             end tell         end if      end tell  end tell  end makecalendarevent  makecalendarevent {"new moon", date ("monday, february 8, 2016 @ 09:39:00"), 0, "", "", date ("monday, february 8, 2016 @ 09:39:00"), true} 

i don't work in applescript entirely possible i've screwed syntax, i've tried alternate syntaxes adding delay between "tell events" using 1 sound alarm , 1 display. @ point i'm wondering if might close it, or if it's 1 of quirks i'm going have live or find end-run around.

any appreciated.

i have tested script several times , had no issue. 2 alarms. made changes optimise script itself, not change logic. of course, did not play parameters, 2 alarms closed (last test 8:00 , 8:05am), still 2 alarms !

makecalendarevent {"new moon", date ("09/02/2016 08:05:00"), 0, "", "", date ("09/02/2016 08:05:00"), true}  on makecalendarevent {eventtitle, eventstart, eventduration, eventdescription, eventurl, alarmtime, setdefaultalarm} --duration (in hours, 0= instantaneous, -1= day) --alarmtime (date or false) --defaultalarm 9am (coded here moment, may move parameter var block @ point) set isallday (eventduration = -1) if eventduration = -1 set eventduration 0  tell application "calendar"     tell calendar "test"         set newevent make new event @ end properties {summary:eventtitle, start date:eventstart, end date:(eventstart + (eventduration * hours)), allday event:isallday, description:eventdescription, url:eventurl}         tell newevent             if alarmtime not false set alarm1 make new sound alarm @ end of sound alarms properties {trigger date:alarmtime}             if setdefaultalarm true set alarm2 make new sound alarm @ end of sound alarms properties {trigger date:(date "08:00 am" of eventstart)}         end tell     end tell end tell     end makecalendarevent 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -