User Defaults and coersion

I have a project that I am working on and I’m experiencing some problems with it. I have set up a number of User Defaults and have a routine for copying the value pairs to a variable list. I have another handler that converts it to a string that I am writing to a data file. It works fine for the base settings that I start with, but when I add new settings the coercion to a string is not working. I have tried logging the class but only get scientific notation.

property basePagePresets : {{presetName:"Tabloid", PresetList:{{"PageWidth", 11}, {"PageHeight", 17}, {"FacingPages", 0}}}, {presetName:"Letter", PresetList:{{"PageWidth", 8.5}, {"PageHeight", 11}, {"FacingPages", 0}}}, {presetName:"A4", PresetList:{{"PageWidth", 8.2677}, {"PageHeight", 11.6929}, {"FacingPages", 0}}}, {presetName:"A3", PresetList:{{"PageWidth", 11.6929}, {"PageHeight", 16.5354}, {"FacingPages", 0}}}}
to getUserDefaults(defaultsList) -- in main script
	set theDefaults to {}
	try
		tell user defaults
			repeat with aDefault in defaultsList
				copy {aDefault, contents of default entry aDefault} to end of theDefaults
			end repeat
		end tell
	end try
	return theDefaults
end getUserDefaults
on writePresets(presetFile, ThePreset) --in loaded library of handlers
	set ASID to AppleScript's text item delimiters
	repeat with p from 1 to count of ThePreset
		repeat with q from 1 to count of PresetList of item p of ThePreset
			set AppleScript's text item delimiters to "-"
			set x to (item 1 of item q of PresetList of item p of ThePreset) as string
			log x --the value here logs fine
			set x to (item 2 of item q of PresetList of item p of ThePreset) as string
			log x --the value here logs fine
			set item q of PresetList of item p of ThePreset to (item q of PresetList of item p of ThePreset) as string
			log (item q of PresetList of item p of ThePreset) --this coerces to an empty string
		end repeat
		set AppleScript's text item delimiters to ", "
		set PresetList of item p of ThePreset to (PresetList of item p of ThePreset) as string
		log PresetList of item p of ThePreset
		set item p of ThePreset to (presetName of item p of ThePreset & ":" & PresetList of item p of ThePreset)
	end repeat
	set AppleScript's text item delimiters to ASCII character 10 --return
	set ThePreset to ThePreset as string
	set AppleScript's text item delimiters to ASID
	
	set PrefsFile to open for access (presetFile) with write permission
	try
		set eof of PrefsFile to 0 -- to overwrite what's there, or leave this line out to append the clipboard to whatever is already in it.
		write ThePreset to PrefsFile
		close access PrefsFile
	on error
		close access PrefsFile
	end try
end writePresets

The resulting file is:

The last entry drops the value pairs after the colon. Any ideas?

Well, I have a work-a-round that seems to be getting the proper results, of course this brings up another problem. One of the values can be from a check box. When setting them through my bound user defaults it works when these have a value of 0 for off or 1 for on, in trial and error if I use true or false when setting these it will not “check”. When I am getting the value of these from the newly created combinations it looks like sometimes it is returning a true or false value. I can check the value and change it accordingly, but I’m would be great if I knew what was happening. Why would the checkbox return a true/false result but not accept a true to “check” the box?

The default class of the value of a checkbox is integer, not boolean.
The return value is also integer, but could have been silently coerced to boolean in some cases

That is what I thought, but I don’t see anywhere that I am coercing it to a boolean. The inconsistent behavior seemed strange but can be dealt with simply enough.