Re: iCal organization with dates & events & lists....
Re: iCal organization with dates & events & lists....
- Subject: Re: iCal organization with dates & events & lists....
- From: Adam Wuellner <email@hidden>
- Date: Fri, 18 Mar 2005 14:20:09 -0600
On Thu, 17 Mar 2005 01:21:05 -0800 (PST), Patrick Collins
<email@hidden> wrote:
> #3. I was unable to find a way to tell iCal to get properties of event
> X, after the events were references [...]
tell application "iCal"
set event_list to events of calendar 1
get properties of contents of item 1 of event_list
end tell
> #2. Calendar events are logged in the order of creation rather than the
> order of start date-- So the list of iCal events that show up in the
> (choose from list) window are not in order by date...... I am wondering
> how is the best way to sort all the items in the (choose by list)
> alphabetically and numerically? I know with the date set the way it is
> currently ("September 18, 2004 11:00:00 PM"), this is extremely
> difficult.. Getting #1 accomplished would allow for sorting to work--
> But still I need to know how to effectively efficiently sort through all
> this stuff in the first place.
Consider this:
(* begin script - watch for word wrap *)
tell application "iCal"
set event_list to {}
repeat with an_event in events of calendar 1
tell contents of an_event
set event_list to event_list & {{uid, start date, summary}}
end tell
end repeat
end tell
set event_list to sort_lists of event_list by 2
set choice_list to {}
repeat with a_list in event_list
set choice_list to choice_list & {short date string of contents of
item 2 of a_list & " - " & contents of item 3 of a_list}
end repeat
choose from list choice_list
-- sort a list of lists by an item in the sublist
on sort_lists of main_list by item_index
local sorted_list, main_list, i, j, item_index
set sorted_list to {contents of item 1 of main_list}
set main_list to rest of main_list
repeat with i from 1 to count main_list
set stored to false
repeat with j from 1 to count sorted_list
if (contents of item item_index of item i of main_list) < (contents
of item item_index of item j of sorted_list) then
if (j > 1) then
set sorted_list to (items 1 through (j - 1) of sorted_list) &
{contents of item i of main_list} & (items j through (count of
sorted_list) of sorted_list)
else
set beginning of sorted_list to (contents of item i of main_list)
end if
set stored to true
exit repeat
end if
end repeat
if stored is false then set sorted_list to sorted_list & {contents
of item i of main_list}
end repeat
return sorted_list
end sort_lists
(*end script *)
I'm not confident there isn't a better algorithm to sort a list of
lists, but that's what I could come up with.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden