Re: How to determine whether an event has an alarm
Re: How to determine whether an event has an alarm
- Subject: Re: How to determine whether an event has an alarm
- From: "Gary (Lists)" <email@hidden>
- Date: Tue, 07 Aug 2007 01:30:58 -0400
"Max Bonilla" wrote:
> Is there a way to determine, through AS, whether an event in iCal has an alarm
> set?
>
> When retrieve the properties of an event I get this: {
> class:event,
> uid:"BFC0A395-549B-4318-8E68-4C6C81DC567B",
> location:missing value,
> url:missing value,
> sequence:0,
> recurrence:"",
> excluded dates:{},
> allday event:false,
> start date:date "Friday, February 10, 2006 12:00:00 PM",
> summary:"Lunch with Bob",
> stamp date:date "Friday, July 20, 2007 1:08:41 PM",
> end date:date "Friday, February 10, 2006 1:00:00 PM",
> description:"##@@B@@@@@@@@@@@@@@
> ",
> status:none
> }
>
> Even if there is an alarm, there is not record showing it. Is there a way to
> figure this out?
If you browse the iCal dictionary in Script Editor, you will note that
alarms are not properties of events, they are elements of events. That's
what the [E] symbol in Script Editor's dictionary viewer is telling you.
Click on 'iCal' in the left-hand pane of suites, then scroll down to the
'event' class (middle pane) to see the elements (right-hand pane).
This will lead you to discover the various alarm classes and their
properties.
So, to discover the existence of alarms of various kinds...
set e_ to item 1 of events of calendar 1 -- or some other event reference
-- ELEMENTS OF AN iCal 'event'
tell e_ to copy its attendees to attendees_
tell e_ to copy its display alarms to alarmsDisplay_
tell e_ to copy its mail alarms to alarmsMail_
tell e_ to copy its open file alarms to alarmsOpenFile_
tell e_ to copy its sound alarms to alarmsSound_
{attendees_, alarmsDisplay_, alarmsMail_, alarmsOpenFile_, alarmsSound_}
--> {{}, {display alarm 1 of event 1 of calendar 1}, {}, {}, {}}
Then you can get 'trigger interval' and 'trigger date' (which does not
properly return missing value or any other usable value if it is empty, so
you'll have to trap for that returned value and handle as needed.)
tell item 1 of item 2 of elems_ to its trigger interval
--> 15
-- bug?
tell item 1 of item 2 of elems_ to (its trigger date)
--> /null result/
tell item 1 of item 2 of elems_ to copy its trigger date to triggerDate_
--> /null result/
-- workaround?
try
tell item 1 of item 2 of elems_ to copy its trigger date to triggerDate_
-- just some tests, to force a 'variable not defined' error
triggerDate_ is in {missing value, "", {}}
on error
copy "(no trigger date)" to triggerDate_
end try
--
Gary
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden