List to text

How to change this list:

{“testing”, {11, 22, 33}, false}

to this string:

testing, “11, 22, 33”, false

HI, cirno.

Something like this?

set theList to {"testing", {11, 22, 33}, false}

try
	-- A deliberate error, to get an error message containing a string representation of the list.
	theList's aardvark
on error msg
	-- Get the error message as plain text
	set {text:msg} to (msg as string)
	msg
end try

-- Edit the message into the required form.
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "\""
set msg to msg's text items
set AppleScript's text item delimiters to ""
set msg to msg as string
set AppleScript's text item delimiters to "{"
set msg to msg's text items
set AppleScript's text item delimiters to "}"
set msg to text items 2 thru -2 of (msg as string)
set AppleScript's text item delimiters to "\""
set theString to msg as string
set AppleScript's text item delimiters to astid

theString
--> "testing, \"11, 22, 33\", false"

a different approach:

set theList to {"testing", {11, 22, 33}, false}

set {TID, text item delimiters} to {text item delimiters, ", "}
set theString to ""
repeat with i in theList
	if class of i is list then
		set theString to theString & ", " & quote & items of i & quote
	else
		set theString to theString & ", " & i
	end if
end repeat
set text item delimiters to TID
set theString to text 3 thru -1 of theString

For this particular list, this is simpler and eliminates the escaped inner quote. Have I missed something? I don’t understand why he wanted the inner list in its own quotes.


set theList to {"testing", {11, 22, 33}, false}

set {TID, text item delimiters} to {text item delimiters, ", "}
set theString to ""
repeat with i in theList
	set theString to theString & ", " & i
end repeat
set text item delimiters to TID
set theString to words of text 3 thru -1 of theString
--> "testing, 11, 22, 33, false"