write a record (with defaults write)

Hi,

I want to write a record to a plist file. Does anyone know if that’s possible? This is what I’m trying to do:


property _domain : "my.domain"

on writeKey(_key, _value)
	do shell script "/usr/bin/defaults write " & quoted form of _domain & space & quoted form of _key & space & quoted form of _value
end writeKey

set Value_as_Record to {item_1:"Value_1", item_2:"Value_2"}

writeKey("My_Key", Value_as_Record)

Thanks in advance.

Bart

Model: G5 dual 1.8
Browser: Safari 417.9.2
Operating System: Mac OS X (10.4)

Hi Bart,

I think this is the effect you are looking for:

do shell script "/usr/bin/defaults write my.domain My_Key '{ item_1 = Value_1; item_2 = Value_2; }'"

To to build up the quoted text from your record you’ll need to make the record item names into text somehow. Are you starting with the record, or making it in the script?

John M

This almost works. It seems that you can’t write an “{” or an “}” with defaults write. But if I change those characters into “(” and “)” I can write something that looks like a record to a plist-file. I use AppleScript’s text item delimiters to create a record of it when I read from the plist-file.

Thanks!

Model: G5 dual 1.8
Browser: Safari 417.9.2
Operating System: Mac OS X (10.4)