iCal uid problems

Hi everyone

I am working on a script that will let me set up repeating todos in iCal. I would like to set up the todo by first setting up an event containing the information for the todo. Then I would like to run a script with that event as the input that will automatically generate another script to be saved and run as an alarm for the same event. There may be an easier way to do this…but this is what I came up with.

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
tell application "iCal"
	activate
	set cb to the clipboard
	set home_cal to calendar "Personal"
	set the_event to first event of home_cal whose summary is cb
	set theName to the summary of the_event
	set theDate to the start date of the_event
	set theURL to the url of the_event
end tell
tell application "AppleScript Editor"
	activate
	make new document with properties {name:theName}
	set the text of document theName to "
	
tell app \"iCal\"
tell" & home_cal & "make new todo with properties{summary:" & theName & ",  due date:" & theDate & ", url:" & theURL & "}
end tell
end tell"
	compile document theName
	save document theName
end tell

I am getting an error when I try to write the values of the variables to the new script.

error:
error “Can’t make «class wres» id "AB41522F-D067-47A2-8476-776F1AB97597" of application "iCal" into type Unicode text.” number -1700 from «class wres» id “AB41522F-D067-47A2-8476-776F1AB97597” to Unicode text

Any help with this script would be great. Or if there is a better/easier way to do this, I am all ears. Thanks

Hi,

the problem is, Script Editor can only compile plain text, no date class, no calendar class.
All variables which contain something else as text must be coerced to text and all text variables which should appear with their values must be quoted


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
tell application "iCal"
	activate
	set cb to the clipboard
	set home_cal to calendar "Personal"
	set the_event to first event of home_cal whose summary is cb
	set theName to the summary of the_event
	set theDate to the start date of the_event
	set theURL to the url of the_event
end tell

tell application "Script Editor"
	activate
	make new document with properties {name:theName}
	set the text of document theName to "
	
tell app \"iCal\"
tell calendar \"Personal\"
make new todo with properties{summary:\"" & theName & "\",  due date: date \"" & (theDate as text) & "\", url:\"" & theURL & "\"}
end tell
end tell"
	compile document theName
	save document theName
end tell