Make calendar in iCal via AS Studio returns error

This script:

set use_this_Calendar to text returned of (display dialog "Enter new iCal calendar name:" default answer "")
tell application "iCal" to make calendar with properties {name:use_this_Calendar}

works great in SE, and iCal obeys faithfully to make a new calendar with the user entered name. However, that same code in a Studio project creates the calendar just fine, but returns an error window with this message:

AppleScript Error

iCal got an error: calendar 13 doesn’t understand the «event panSdlog» message. (-1708)

Here is the current flow: Main window opens, generates a popup menu with all the names of current iCal calendars. The last item in the list is “Make New Calendar”, and when that is chosen in the choose menu item handler, goes to a handler with the above script. iCal immediately creates the calendar, but instead of returning to the choose menu item handler, it throws this box up.

I have not scripted iCal much at all, is this some sort of unique Studio related behavior?

«event panSdlog» seems to be the event for display dialog. Try telling iCal or your application instead.

Side note: Chevrons [«»] can be typed by pressing Option+\ and Option+Shift+\ (on my US keyboard, at least).


Aaahhh! Yeah, that makes sense. I threw a display dialog inside the choose menu item handler to double check my results after the call to the MakeNewCalendar handler. I’ll take it out when I get to work tomorrow and see.

« » Looks like the sideways chevrons come out from my keyboard directly as well. Thanks for the tip, Bruce.