Write to File outputs wrong text

In an attempt to write output of an EKEvent to a text file,

	write theText to theOpenedFile starting at eof as list

the following text, as seen in source mode in Script Debugger:

{event_external_ID:“4p6vs356306uin8g1sd47eh8pi@google.com”, event_location:“San Jose, CA”, event_end_date:date “Friday, June 8, 2018 at 12:00:00 AM”, event_start_date:date “Monday, June 4, 2018 at 12:00:00 AM”, event_time_zone:missing value, event_status:“confirmed”, event_description:"A … }

and, as seen in AEPrint mode in Script Debugger:

{ ‘usrf’:[ ‘utxt’(“event_external_ID”), ‘utxt’(“4p6vs356306uin8g1sd47eh8pi@google.com”), ‘utxt’(“event_location”), ‘utxt’(“San Jose, CA”), ‘utxt’(“event_end_date”), 'ldt '($80773FD700000000$), ‘utxt’(“event_start_date”), 'ldt '($80313AD700000000$), ‘utxt’(“event_time_zone”), ‘msng’, ‘utxt’(“event_status”), ‘utxt’(“confirmed”), ‘utxt’(“event_description”), ‘utxt’("A …}

ended up as the following text in the text file:

◊0˚yutxt&event_original_datetypemsngutxtevent_attendeeslistutxt$event_is_recurringfalsutxtevent_summaryutxtTest eventutxtcalendar_nameutxtPersonal Webrecousrflist"utxt"event_external_IDutxtJ4p6vs356306uin8g1sd47eh8pi@google.comutxtevent_locationutxtSan Jose, CAutxtevent_end_dateldt ◊?wÄutxt event_start_dateldt ◊:1Äutxtevent_time_zonetypemsngutxtevent_statusutxtconfirmedutxt"event_descriptionutxtÍA …

Using Standard Additions’ write command I used list as the type class, as both text and data type classes failed with the write command.

  1. How do I write data to a file, so as to output the event data in a readable format?
  2. If this is not possible, can I save EventKit’s events as an ics, ie in a more standard manner for importing events?

My overall goal is to import the EKEvent event data into Filemaker Pro.

What you’re dealing with there is not a list, it’s a record. You extract values from a record via the labels, for example:

set theID to event_external_ID of someRecord

You can save it as a record. Or you can convert it to a property list and save that.

No. You’d have to build your own ics data.

Writing the EKEvent record as a record,

	write theText to theOpenedFile starting at eof as record

recousrflist"utxt"event_external_IDutxtJ4p6vs356306uin8g1sd47eh8pi@google.comutxtevent_locationutxtSan Jose, CAutxtevent_end_dateldt ◊?wÄutxt event_start_dateldt ◊:1Äutxtevent_time_zonetypemsngutxtevent_statusutxtconfirmedutxt"event_descriptionutxtÍA…

The file remained unreadable.
Creating a property list with labels and values

	tell application "System Events"
		make new property list item with properties {value:TargetRecord}
		set {labelLists, valueLists} to {name, value} of property list item of result
	end tell

{{“event_external_ID”, “event_location”, “event_end_date”, “event_start_date”, “event_time_zone”, “event_status”, “event_description”, “event_url”, “event_organizer”, “calendar_type”, “all_day”, “event_creation_date”, “event_original_date”, “event_attendees”, “event_is_recurring”, “event_summary”, “calendar_name”}, {“4p6vs356306uin8g1sd47eh8pi@google.com”, “San Jose, CA”, date “Friday, June 8, 2018 at 12:00:00 AM”, date “Monday, June 4, 2018 at 12:00:00 AM”, missing value, “confirmed”, "A…

but then attempts to write as record erred with:
Error: unable to coerce the data to the desired type (errAECoercionFail:-1700)

Perhaps you can provide an example or point me to another discussion, on methods to succeed at writing an Event record that is either readable or importable to Filemaker, which is my overall goal.
Thanks for your help.

If you write as record, you then have to read as record.

It sounds like you want something like tab-delimited of CSV. But there’s no magic tool for that: you need to take the record, and create the new format from it.

Otherwise it’s something like, in pseudo-code:

set value of cell "Location" to event_location of eventRecord