iCal Date issue

Hi I am new to the forum and applescript in general and am having some trouble with iCal.
I am trying to create an event in iCal based on info in a FileMaker 7 database. I have everything working the way I need apart from the start date, it will always add the event in as today, not the date specified in the database.

Here is the script


tell application “FileMaker Developer”

go to layout "event" of database "RunningM8"

set EventName to cell "iCal Title"
set EventDate to cell "Event Date"
set EventLocation to cell "Event Location"
set EventURL to cell "Event URL"
set EventDescription to cell "iCall Description"

end tell

tell application “iCal”

set this_calendar to (the first calendar whose title is the "Races")

tell this_calendar
	
	make new event at end of events of this_calendar with properties {summary:EventName, location:EventLocation, description:EventDescription, start date:EventDate, allday event:true, url:EventURL}
	
end tell

end tell

It will input all the properties except the date.

Is there something obvious I have done wrong

Thanks for your help

Sincerely

Orlando

Hi,

AppleScript ‘date’ begins with the reserved word ‘date’. An AppleScript date is not a string (surrounded by quotes).

Try looking at the result of:

tell application “FileMaker Developer”

     go to layout "event" of database "RunningM8" 
      
     set EventName to cell "iCal Title" 
     set EventDate to cell "Event Date" 

end tell

Check if it is a string or an AppleScript ‘date’.

iCal uses AppleScript dates (begins with the keyword ‘date’) for ‘start date’.

There are a couple or more ways to coerce date strings to AppleScript date. Here’s an example:

set cur_date to (current date) – AppleScript date
set date_and_time_string to (cur_date as string) – date and time as string
set date_string to (date string of cur_date) – just the date and no time as string
set time_string to (time string of cur_date) – just the time as string
– coerce back to AppleScript date
return date date_and_time_string – coerce to AppleScript date
– return date date_string – coerce to AppleScript date at midnight
– return date time_string – coerce to AppleScript date for today at time time_string

Note that AppleScript will take any info provided and try to coerce to date or error if not possible.

I don’t have Filemaker, but suspect it is probably returning a string from the cell.

gl,

Thanks Kel, it was the date format.
FileMaker was bringing the date through as “27/11/2004” so adding another step to change the format into an AppleScript date solved the problem.

The final script looks like this

tell application “FileMaker Developer”

go to layout "event" of database "RunningM8"

set EventName to cell "iCal Title"
set FileMakerDate to cell "Event Date"
set EventLocation to cell "Event Location"
set EventURL to cell "Event URL"
set EventDescription to cell "iCall Description"

end tell

set EventDate to date FileMakerDate

tell application “iCal”

set this_calendar to (the first calendar whose title is the "Races")
tell this_calendar
	make new event at end of events of this_calendar with properties {summary:EventName, location:EventLocation, description:EventDescription, start date:EventDate, allday event:true, url:EventURL}
	
end tell

end tell

Thanks again

Sincerely

Orlando