iCal organization with dates & events & lists....
iCal organization with dates & events & lists....
- Subject: iCal organization with dates & events & lists....
- From: "Patrick Collins" <email@hidden>
- Date: Thu, 17 Mar 2005 01:21:05 -0800 (PST)
- Organization: Collinator Studios
ok here's the deal.. I wrote a script
which would gather all events &
data from within a chosen calendar... Then you select the event you
desire, and it creates a new email in mail.app and adds all of the
event's info to the mail document (attendee, start & end date,
location,
notes, etc)............
My problem is this:
#1. When the start date of a calendar event is obtained, it appears as
the long format "September 18, 2004 11:00:00 PM" for example... Now,
from what I understand, you can normally treat variables defined as
(current date) in a way that you can ask for the date in short-date
form.. or just get the day, hour, etc... However, the date retreived
by my script is not really a "date".. so I can't do anything like that
to it.. I basically want the dates to show up as "9/18/04 11:00 PM"
exactly.. but I don't know how the best way to do this is-- is there a
simple way to say datestring = a date-- so then you can modify it like
a
date? Or do I need to do text delimiters, etc, and then set up a list
of months, and make the program determine, if the first part is
September then that = 9, etc.. My script already runs rather slow, so
I
am trying to avoid any extraneous tasks like this.
#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.
#3. I was unable to find a way to tell iCal to get properties of event
X, after the events were references... This makes no sense to me, so
as
of now my script is creating a list of all event attributes of all
events before it allows you to choose an event.. very inefficient----
So this is one reason why my script is so long.. but it seems that
once
I got the name of the events to place into my list, and once my repeat:
set event_list to calendar string_fun's events
repeat with event_cur in my 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 uid_list to uid
end tell
end repeat
was completed, if I tried anything like.. get the summary of the event
whose UID is (item N of uid_list).. I would get insane errors.. and it
drove me CRAZY, and could not figure it out.. and I looked in the
dictionary for days and days.. and I screamed "WHY CANT APPLE'S
DICTIONARY ENTRIES HAVE MORE INFORMATION!?!?!?!?"...
so anyway............ if you have some thoughts and want to look over
this script, that would be cool..
the code 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 my 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 my 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
set spaceflag to false
set UpperCase to "ABCDEFGHIJKLMNOPQESTUVWXYZ"
set LowerCase to "abcdefghijklmnopqrstuvwxyz 1234567890"
set theString to (the_attendee as string)
set theCharacters to characters of theString
set tmpWords to {}
set tmpWord to ""
repeat with tmpChar in theCharacters
set tmpChar to (tmpChar as string)
considering case
if tmpChar is in UpperCase then
if not spaceflag then
if tmpWord is not "" then copy tmpWord
to the end of tmpWords
set tmpWord to tmpChar
else
set tmpWord to (tmpWord & tmpChar)
as string
end if
else if tmpChar is in LowerCase then
if tmpChar = " " then
set spaceflag to true
else
set spaceflag to false
end if
set tmpWord to (tmpWord & tmpChar) as
string
end if
end considering
end repeat
copy tmpWord to the end of tmpWords
set AppleScript's text item delimiters to {", "}
set tmpWords to (tmpWords as string)
set AppleScript's text item delimiters to {""}
try
set the_message to the_message & "Attendees: " &
tmpWords & 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
thank you................
_________________
-patrick collins
http://collinatorstudios.com
_______________________________________________
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