Calendar + icalbuddy script crashes Script Editor

Hello everyone!

I have a bit of a problem ” I managed to write script that crashes Script Editor! Here’s the culprit:



set rawOutput to do shell script "/usr/local/bin/icalBuddy -npn -nc -iep 'title,datetime' -ps ' ^ ' -po 'datetime,title' -df '' -eed -b '' -n -ea eventsToday"

set eventList to {}
set now to time of (current date)

repeat with i in paragraphs of rawOutput
	set AppleScript's text item delimiters to "^"
	set startTime to first text item of i
	set eventName to second text item of i
	set myEvent to {startTime, eventName}
	copy myEvent to end of eventList
end repeat

-- it crashes here
repeat with myEvent in eventList
	set startTime to time of date (item 1 of myEvent) as string
	if item 1 of startTime > now then copy myEvent to end of eventList
end repeat

return eventList


I’m not an experienced programmer, my adventures with AS are of the hack-and-tape-together nature, therefore I’m not sure what did I do to make Script Editor explode like that. It was working normally just a few days ago. Any help would be appreciated!

EDIT: here’s the crash report → http://pastebin.com/Ruf3E28R

Model: Macbook Pro Retina 15"
AppleScript: 2.5
Browser: Safari 601.5.13
Operating System: Mac OS X (10.10)

Hi,

I have no idea what icalBuddy returns but it’s most likely a date string format that cannot be used as argument to create an AppleScript date.

Thank you for the quick reply. You got me thinking and I rebuilt the script pretty dramatically, fixing the crash in the process. Here it is, if anyone is interested:

set rawOutput to do shell script "/usr/local/bin/icalBuddy -npn -nc -iep 'title,datetime' -ps ' ^ ' -po 'datetime,title' -df '' -eed -b '' -n -ea eventsToday"

set eventList to {}
set now to time of (current date)
set startTimes to {}


repeat with myEvent in paragraphs of rawOutput
	set myEvent to myEvent as list
	set startTime to time of date (item 1 of myEvent)
	if startTime > now then copy myEvent to end of eventList
end repeat

repeat with myEvent in eventList
	set myEvent to myEvent as string
	set AppleScript's text item delimiters to "^"
	copy text item 1 of myEvent to end of startTimes
	set AppleScript's text item delimiters to ""
end repeat

return startTimes -- returns {"2:00 PM", "2:00 PM", "7:00 PM"} 


Question: how to compare items in startTimes list and figure out if there are any that are identical? I basically want it to tell me “true” if at least 2 are the same or false if all are different.

BTW icalbuddy returns a string. rawOutput returns the following:

[format]“11:30 AM^MashApp
2:00 PM^Design Review
7:00 PM^IASIP”[/format]

My goal here is to construct a script that tells me name of the next event of my calendar and time remaining. I’m going to use it with Ubersicht.