Error messages.

How can I turn for example {button returned:“OK”} into “{button returned:"OK"}” which would look like the 1st in a dialog. (for ASOC, cocoa welcome)

I am not sure I understand what you want. The result from display dialog is a record, not an error message (you set the title of this thread to “Error messages.”). Errors are caught (and handled) by try blocks, but display dialog will not generally cause an error (unless you count the “invisible” error number -128 that is created if the user clicks Cancel).

If you want to convert the record to a AppleScript source code string that represents the record, there is an ugly hack that can be done with plain AppleScript. A better way would probably be to use an OSAX or application to do such conversions (if such a thing exists).

set a to display dialog "Press OK"
set b to convertRecordToString(result)
set c to run script b -- the converted result might be usable as source code (wrapping a "using terms from" block around if might be necessary, though)
{a, b, c, a is c} --> {{button returned:"OK"}, "{button returned:\"OK\"}", {button returned:"OK"}, true}

to convertRecordToString(r)
	 * Ugly hack:
	 *  Force a bogus coercion that will always throw an error.
	 *  Extract the string representation from the resulting error message.
		r as data -- anything except list should do the trick
	on error m
		-- m should be something like:
		-- "Can't make {button returned:\"OK\"} into type data."
		set l to length of m
		set a to 1
		set b to l
		repeat until a is greater than l or ¬
			text a through a of m is "{"
			set a to a + 1
		end repeat
		repeat until b is less than a or ¬
			text b through b of m is "}"
			set b to b - 1
		end repeat
		if a is greater than l or b is less than a then ¬
			error "Unable to convert record to string." number 100
		return text a through b of m
	end try
	error "Unable to convert record to string." number 101
end convertRecordToString


It generally use this dirty hack:

to GetRecordAsString(rec)
		result as string
	on error errTxt
		set obrace to offset of "{" in errTxt
		set cbrace to offset of "}" in errTxt
		text obrace thru cbrace of errTxt
	end try
end GetRecordAsString

display dialog "Hello World" with title "" buttons {"Cancel", "OK"} default button 2

… oooppps, Chris fired first. (after all, he’s Texan ;o)