I am desperately trying to create a new event in iCal with Applescript
everything works except the time slot.
I did try previous posting on this site, none of them seem to work for me.
OSX 10.3.9
her is my code including some “garbage” that I tried to solve the problem:
(*on run { sDate, eDate, theSummary, theDescription}*)
tell application "iCal"
launch
set theText to the "theSummary"
set theDescription to "just testing"
set DT to the (current date)
set sDate to " 27 September 2005"
set eDate to " 11:50:02"
set fDate to (sDate & " " & eDate) as string
set theDate to fDate as string
set newEvent to make new event at end of events of calendar 1 with properties ¬
{start date:sDate, end date:eDate, summary:theText, description:theDescription}
set start date of newEvent to theDate
end tell
(*end run*)
error message:
make new event at end of every event of calendar 1 with properties {start date:" 27 September 2005", end date:" 11:50:02", summary:“theSummary”, description:“just testing”}
event 202 of calendar 1
set start date of event 202 of calendar 1 to " 27 September 2005 11:50:02"
“iCal got an error: NSUnknownKeyScriptError”
also note that Applescript creates an event with current date = ignores my date
Any help wpu;d be greatly appreciated
Gerd
Model: G5
AppleScript: 1.9.3
Browser: Firefox 1.0.6
Operating System: Mac OS X (10.3.9)
You’re on the right track, but a couple things. First, you have 2 dates in your script, the current date, and the date you’re building. You’ve got kind of a mess with the latter, as you say. What you’re missing essentially is that you need to explicitly coerce your text to date, which iCal can use. This works:
set sDate to “27 September 2005”
set eDate to " 11:50:02"
set fDate to date (sDate & " " & eDate)
– returns (on my system): date "Tuesday, September 27, 2005 11:50:02 AM
Thank you Fenton for your reply.
I sort of got it working.
I cannot convert the variable to a date object in one go
It always throws an error message
However it works if I declare the variable as a date first
then on the next line I can add the new data:
set MyDate to date
set MyDate to date “Thursday, 29 September 2005 09:50:00”
now my problem is when I import data from another application.
RealBasic 5.5)
the strings are identical, yet somehow the Applescipt does not work anymore
Tried encoding to UTF 8 and 16 - does not help
Any ideas?
Gerd
on run {sDate, eDate, theSummary, theDescription}
tell application “iCal”
launch
set MyDate to date
set theDate to date
(*set theDate to date "Thursday, 29 September 2005 09:45:00"
set MyDate to date "Thursday, 29 September 2005 09:50:00"
set theSummary to "Summary"
set theDescription to "just testing"*)
set theDate to date sDate
set MyDate to date eDate
set newEvent to make new event at end of events of calendar 1 with properties ¬
{start date:theDate, end date:MyDate, summary:theSummary, description:theDescription}
end tell
end run
Model: G5
AppleScript: 1.9.3
Browser: Firefox 1.0.6
Operating System: Mac OS X (10.3.9)