• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iCal alarm scripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iCal alarm scripts


  • Subject: Re: iCal alarm scripts
  • From: "Nigel Garvey" <email@hidden>
  • Date: Fri, 15 Jan 2010 19:04:04 +0000

Josh Tishhouse wrote on Fri 15 Jan 2010 11:27:29 -0500:

>How do I separate out the resultant set (event, Calendar)?
>
>I thought I'd try this:
>
>set AppleScript's text item delimiters to {","}
>set theEvent to item 1 of candidates
>
>But that didn't work.

'candidates' is a list of lists, each sublist containing an event/
calendar index pair, so you'd need something like this:

  set {e, c} to item 1 of candidates
  tell application "iCal"
    set theEvent to event e of calendar c
    -- Get the details you want from theEvent here.
  end tell

Hopefully, there'll only be one 'candidate' list in 'candidates', but
there could be more if different events triggered the script at roughly
the same time.

NG

>On Jan 11, 2010, at 2:30 PM, Nigel Garvey wrote:

>>  on myEvent()
>>    set now to (current date)
>>    set leeway to 5 -- Allow, say, 5 seconds for the script to respond
>> to the alarm.
>>
>>    tell application "System Events" to set myUrl to URL of (path to me)
>>
>>    tell application "iCal" to set myInstances to (open file alarms of
>> events of calendars whose filepath is myUrl)
>>    return result
>>    --> A list containing lists corresponding to the calendars,
>> containing lists
>>    --> corresponding to the events, containing nothing or matching
alarm(s).
>>
>>    set evntCal_Indices to {}
>>    repeat with c from 1 to (count myInstances)
>>      set thisCal to item c of myInstances
>>      repeat with e from 1 to (count thisCal)
>>        set thisEvnt to item e of thisCal
>>        repeat with alrm from 1 to (count thisEvnt)
>>          tell application "iCal" to set timeDiff to (start date of
>> event e of calendar c) + (trigger interval of item alrm of thisEvnt) *
>> minutes - now
>>          if (timeDiff > -leeway) and (timeDiff < leeway) then set end
>> of evntCal_Indices to {e, c}
>>        end repeat
>>      end repeat
>>    end repeat
>>
>>    return evntCal_Indices -- event/calendar index pairs.
>>  end myEvent
>>
>>  set candidates to myEvent()
>>  --> {{11, 4}} -- One candidate found: event 11 of calendar 4.
>>
>>
>> NG _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> AppleScript-Users mailing list      (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>@gmail.com
>> Archives: http://lists.apple.com/archives/applescript-users
>>
>> This email sent to email@hidden
>


 _______________________________________________
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

  • Follow-Ups:
    • Re: iCal alarm scripts
      • From: Josh Tishhouse <email@hidden>
References: 
 >Re: iCal alarm scripts (From: "Nigel Garvey" <email@hidden>)
 >Re: iCal alarm scripts (From: Josh Tishhouse <email@hidden>)

  • Prev by Date: A bug and an annoying behavior related to Spaces
  • Next by Date: Re: File Duplication Question
  • Previous by thread: Re: iCal alarm scripts
  • Next by thread: Re: iCal alarm scripts
  • Index(es):
    • Date
    • Thread