Hi new to AppleScript so I am probably missing something obvious. But I have written a script that imports an iCal event into filemaker. With a lot of code snipets from here. (Thanks All). It is working well except if the Location or Description fields in iCal are blank or empty. It gives me an error message when I try to put a blank or empty value into the field. I have tried various If/Then’s to script around this with no success. Any help would be appreciated. Here is the script:
[NOTE: I added the AppleScript tags so folks could easily copy this to their own Script Editor - Adam Bell]
tell application "iCal" to activate
tell application "System Events"
tell process "iCal"
keystroke return
keystroke "c" using {command down}
keystroke return
end tell
end tell
set TheLocation to " "
set TheDescription to " "
tell application "iCal"
activate
set cb to the clipboard
set the_cal to calendar "Exchange"
set the_event to first event of the_cal whose summary is cb
set TheStartDate to start date of the_event
set TheSummary to the summary of the_event
set TheEndDate to the end date of the_event
set TheDescription to the description of the_event
set TheLocation to the location of the_event
set TheUID to the (uid of the_event as string)
set start_time_string to (time string of TheStartDate)
set end_time_string to (time string of TheEndDate)
tell start_time_string
set start_time_without_sec to (word 1 & ":" & word 2 & space & word 4)
end tell
tell end_time_string
set end_time_without_sec to (word 1 & ":" & word 2 & space & word 4)
end tell
end tell
tell application "FileMaker Pro"
activate
tell database "GTD"
tell table "Meeting"
set theRecord to create new record
set data of field "MeetingSubject" of theRecord to TheSummary
set data of field "MeetingLocation" of theRecord to TheLocation
set data of field "iCalUID" of theRecord to TheUID
set data of field "MeetingDate" of theRecord to my formatDate(TheStartDate)
set data of field "MeetingTime" of theRecord to start_time_without_sec
set data of field "MeetingEndTime" of theRecord to end_time_without_sec
set data of field "IniCal" of theRecord to "Yes"
set data of field "Status" of theRecord to "Confirmed"
set data of field "Agenda" of theRecord to TheDescription
end tell
end tell
end tell
on formatDate(aDate)
try
set fmDateString to ((month of aDate as integer) as string) & "/" & ((day of aDate as integer) as string) & "/" & ((year of aDate as integer) as string)
return fmDateString
on error errMsg number errNum
error ("formatDate error: " & errMsg) number errNum
end try
end formatDate
Thanks in Advance,
George
Model: MacBook Pro
Browser: Safari 419.3
Operating System: Mac OS X (10.4)