Excuting AppleScript from Java application - NewBie

Hi. I initially posted this on the Apple discussion boards but by the looks of it, this might be a better place to post! :slight_smile:

I’m working on a little project that extracts events from iCal using AppleScript and populates a pdf document using Java. The applescript would be executed from within a simple Java program.

  1. The applescript to get the events from iCal is working fine. All it does is get all the events from my work calendar between a specified date range. That’s it.
  2. The executing of the applescript from the java program is no problem.
  3. The NSAppleEventDescriptor I get from the executed AppleScript does contain the correct number of items. However, I’m completely lost when trying to get the iCal events data from the NSAppleEventDescriptor.

Does anybody have any idea what format the events would be in when returned in the NSAppleEventDescriptor?

Here’s the AppleScript that I use:

property pCalName : "Work"
property sDate : date "Tuesday, 1 July 2003 12:00:00 AM"
property eDate : date "Thursday, 31 July 2003 12:00:00 AM"

tell application "iCal"
set allCals to title of calendars
set calIndex to (my getIndex(pCalName, allCals))
set mailCal to calendar calIndex

get every event in mailCal whose (start date is greater than sDate) and (end date is less than eDate)

end tell

on getIndex(theItem, theList)
repeat with i from 1 to count of theList
if theItem is item i of theList then
return i
end if
end repeat
return -1
end getIndex

I’m actually working on a script that doesn’t use the getIndex function but the gathering of the events will still be the same. What I would like to do next, it parse the data and get the start and end timestamps for each event - which, as soon as I get that information in Java, I’ll be able to do wild and crazy things! :wink:

Thanks,
Rob