ical again

ok… I know i keep posting about this ical script…

So far I have it working… The only issues that are remaining are:

  1. It is currently creating lists out of every possible calendar event in order for it to extract the data from the chosen event… This is incredibly inefficient… So I ask again-- does ANYONE know of a way that I can say in applescript: get summary of event X of calendar Y?

  2. my event list is apparently being sorted by event creation, rather than actual event date occurance… Can anyone please explain how I might resolve this issue so that they will chronologically be listed?

most recent script version is:


set string_fun to 1
set list_number to 0
set event_choose to {}
set final_location to ""
set final_url to ""
set uid_list to {}
set attendee_list to {}
set summary_list to {}
set description_list to {}
set startdate_list to {}
set enddate_list to {}
set status_list to {}
set url_list to {}
set location_list to {}
set final_description to ""
set final_status to ""
tell application "iCal"
	activate
	set visible of window "iCal" to true
	set the_cal to the title of every calendar
	set list_choice to (choose from list the_cal)
	set list_string to (list_choice as string)
	repeat with list_number in the_cal
		set descriptionval to {item string_fun of the_cal} as string
		if descriptionval = list_string then
		else
			set string_fun to string_fun + 1
		end if
	end repeat
	
	set event_list to calendar string_fun's events
	repeat with event_cur in event_list
		tell event_cur
			set editdate to (start date as string)
			set the end of event_choose to editdate & "   " & summary
			set the end of summary_list to summary
			set the end of startdate_list to start date
			set the end of enddate_list to end date
			set the end of location_list to location
			set the end of url_list to url
			set the end of description_list to description
			set the end of status_list to status
			set the end of attendee_list to {display name of attendees}
			set the end of uid_list to uid
		end tell
	end repeat
	
	set event_choice to (choose from list event_choose)
	
	repeat with I from 1 to (count of event_choose)
		set char_line to item I of event_choose
		
		if (char_line as string) is equal to (event_choice as string) then
			
			set the_uid to item I of uid_list
			set the_summary to item I of summary_list
			set the_startdate to item I of startdate_list
			set the_enddate to item I of enddate_list
			set the_location to item I of location_list
			set the_url to item I of url_list
			set the_attendee to item I of attendee_list
			set the_status to item I of status_list
			set the_description to item I of description_list
			
			exit repeat
		end if
	end repeat
end tell

set the_sub to "Calendar Information"
set the_sender to ""
set the_message to "Automatic iCal email notifaction!" & return & return & "Event Summary: " & the_summary & return
set the_message to the_message & "Start Date: " & the_startdate & return
set the_message to the_message & "End Date: " & the_enddate & return
try
	
	set the_message to the_message & "Location: " & the_location & return
on error number -2753
end try
try
	set the_message to the_message & "Event URL: " & the_url & return
on error number -2753
end try


try
	set the_message to the_message & "Event Description: " & the_description & return
on error number -2753
end try
try
	set the_message to the_message & "Event Status: " & the_status & return
on error number -2753
end try
try
	set the_message to the_message & "Attendees: " & the_attendee & return
on error number -2753
end try
tell application "Mail"
	activate
	set newMessage to make new outgoing message with properties {subject:the_sub, content:the_message}
	tell newMessage
		set visible to true
	end tell
end tell