Voici une version légèrement plus élaborée, qui peut être assez
facilement adaptée, je pense....
--SCRIPT
--Script de Kim Hunter, légèrement modifié.
--SortCalendar(pDate_Debut, pduration_in_Days, ppcalendar_index) --
La routine renvoie une liste d' évènements Ical triée par
chronologie. Le premier argument est la date du début de la recherche
d'évènements, le second la durée en jour pendant laquelle on
collecte les évènements, le dernier est le N° du calendrier. Pour
exploiter, les propriétés des évènements, il faut revenir dans le
contexte de Ical
property pDate_Debut : (current date)
property pduration_in_Days : 2
property pcalendar_index : 1 --Numero d'ordre de calendrier.
if my SortCalendar(current date, pduration_in_Days, pcalendar_index)
is not {} then
tell application "iCal"
set dlg2 to {}
repeat with i in my SortCalendar(current date, pduration_in_Days,
pcalendar_index)
set a to summary of i
set b to start date of i
set dlg1 to (a as string) & " - " & "jour :" & day of b & " - " &
"Heure: " & time string of b & return
set dlg2 to dlg2 & return & dlg1 as string
end repeat
return dlg2
--activate
--display dialog dlg2 giving up after 5
end tell
end if
on SortCalendar(pDate_Debut, pduration_in_Days, ppcalendar_index)
tell application "iCal"
set FList to every event of calendar ppcalendar_index whose start
date is greater than (pDate_Debut)
set FutureEventList to {}
repeat with i from 1 to count FList
if (start date of item i of FList is less than ((pDate_Debut) +
pduration_in_Days * days)) then
set end of FutureEventList to item i of FList
end if
end repeat
set SortedEventList to my sortEvents(FutureEventList)
return SortedEventList
end tell
end SortCalendar
on findLeastItem(lst)
tell application "iCal"
set theLeast to start date of item 1 of lst
set theIndex to 1
set iterater to 1
repeat with i in lst
if start date of i ≤ theLeast then
set theLeast to start date of i
set theIndex to iterater
end if
set iterater to iterater + 1
end repeat
return theIndex
end tell
end findLeastItem
on removeItemAtIndex(lst, theIndex)
set newList to {}
set theLength to length of lst
if theLength = 1 then
set newList to {}
else if theLength = theIndex then
set newList to items 1 thru (theLength - 1) of lst
else if theIndex = 1 then
set newList to items 2 thru theLength of lst
else
set newList to items 1 thru (theIndex - 1) of lst & items (theIndex
+ 1) thru (theLength) of lst
end if
return newList
end removeItemAtIndex
on sortEvents(myList)
set myNewList to {}
repeat until length of myList = 0
set leastIndex to findLeastItem(myList)
set end of myNewList to item leastIndex of myList
set myList to removeItemAtIndex(myList, leastIndex)
end repeat
return myNewList
end sortEvents
--SCRIPT_______________________________________________
Applescript_fr mailing list
Applescript_fr@???
http://listes.patpro.net/mailman/listinfo/applescript_fr