Hello everyone!
This is my first post AND first project with AppleScript. Obviously I am having some issues or I wouldn’t be here writing this. I made a fairly simple interface with XCode / Interface Builder which has the following fields:
title
url
notes
month
day
year
add (button element)
With the exception of the Add button those are all text fields. All of that is “wrapped” inside the window with the long menu bar at the top of it. I am sure you know what I mean. I have 6 menu buttons going across the window at the top:
DVD
GameBoy
GameCube
PC
PlayStation 2
XBox
The goal is to fill out the field under the desired media category and when you click the Add button, it creates an entry in my “Games & DVDs” calendar.
The interface appears to be working correctly so I am 99.9999% sure it has to do with my AppleScript. This is what I have in my myproject.applescript file:
on clicked theObject
tell application "iCal"
set calTitle to "Games & DVDs"
if tabView is "dvd" then
set location of events to DVD
else if tabView is "gameBoy" then
set location of events to GameBoy
else if tabView is "gameCube" then
set location of events to GameCube
else if tabView is "pc" then
set location of events to PC
else if tabView is "playStation2" then
set location of events to PlayStation2
else if tabView is "xBox" then
set location of events to XBOX
end if
set add to make new event at the end of events of (item 1 of (calendars whose title is calTitle))
with transaction
{start date:date, summary:title, description:notes}
end transaction
end tell
end clicked
That “with transaction” near the end I read should be an “with properties” but XCode kept giving me errors.
So if any one out there has a few free minutes, I would really appriciate some help.
Thanks in advance,
Abraham
UPDATE:
Messed around with the code some more and am getting this error now (so at least something is working):
iCal got an error: NSCannotCreateScriptCommandError (10)
My AppleScript now looks like this:
on clicked theObject
tell application "iCal"
set calTitle to "Games & DVDs"
if window is "dvd" then
set location of events to DVD
else if window is "gameBoy" then
set location of events to GameBoy
else if window is "gameCube" then
set location of events to GameCube
else if window is "pc" then
set location of events to PC
else if window is "playStation2" then
set location of events to PlayStation2
else if window is "xBox" then
set location of events to XBOX
end if
set add to make new event at the end of events of (item 1 of (calendars whose title is calTitle))
with transaction
{start date:date, summary:title, description:notes}
end transaction
end tell
end clicked