Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > (AppleScript) iCal event class not really scriptable?

(AppleScript) iCal event class not really scriptable?
Thread Tools
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Sep 9, 2004, 05:35 AM
 
Hi,

I was wondering if anyone can see if I'm missing something here:

Is iCal's scripting rather weird? I seem to be able to create new calendars and events via applescript - but cannot "query" existing event objects.

e.g.

[php]
tell application "iCal"
set foo to event 1 of calendar 1
log foo
log class of foo
end tell
[/php]

doesn't work (NSCannotCreateScriptCommandError)

[php]
tell application "iCal"
set firstCal to first calendar
get description of firstCal

get every event of firstCal
end tell[/php]

also doesn't work ("iCal got an error: NSCannotCreateScriptCommandError")

Does iCal just not allow this kind of thing?
     
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Sep 9, 2004, 07:37 AM
 
Assuming you know the calendar number (if not you need to use a whode clause by title),[php]tell application "iCal"
set iCalendar to calendar 1
tell iCalendar
make new event with summary "My New Event"
end tell
end tell[/php]

You can use a try block with 'get first event whose summary is "My new Event"' to access the event. Add a date parameter to further define the shose clause if appropriate.

HTH
Craig
     
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status: Offline
Reply With Quote
Sep 10, 2004, 11:25 AM
 
I am able to get information like this:

Code:
tell application "iCal" tell the first calendar get the start date of the first event end tell end tell
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Sep 11, 2004, 10:29 AM
 
Hmmm - that gives me "NSCannotCreateScriptCommandError" - Is my copy of iCal broken? I am using v.1.5.3
     
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status: Offline
Reply With Quote
Sep 11, 2004, 01:13 PM
 
Originally posted by Diggory Laycock:
Hmmm - that gives me "NSCannotCreateScriptCommandError" - Is my copy of iCal broken? I am using v.1.5.3
It could be... but I am also using a non 10.3 OS... so it could have been broken bug got fixed... someone with 10.3 want to verify?

Oh... and you do have a calendar defined in iCal, yes?
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Sep 11, 2004, 01:59 PM
 
I'm using an up to date version of the OS - that version was for iCal.

Yes - I have 4 calendars.
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Sep 11, 2004, 02:07 PM
 
How very bizarre - I just tried scripting iCal again - and now it's fine.

Must have been a temporary iCal spasm.

Thanks everyone.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:13 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2