View Single Post
FWIW I have generalized the above with a function which serializes a specified sub-set of the properties of an object into a list of {property name, property value} pairs, which can be written to a plist file.

Inelegant, but serviceable enough, I think:

Code:
-- SERIALIZE THE RELEVANT PROPERTIES OF AN OBJECT AS A LIST OF KEY-VALUE PAIRS,
-- TO BE WRITTEN TO A PLIST FILE
on Serialize(oObject, lstProps)
	set lst to {}
	repeat with oKey in lstProps
		set end of lst to {oKey, my GetProp(oKey, oObject)}
	end repeat
	return lst
end Serialize

on GetProp(strPropName, oObject)
	run script "
		on run {refObject}
			get " & strPropName & " of refObject
		end run
" with parameters {oObject}
end GetProp