-- delimiter : The delimiter used to join the text.
-- someList : The list to be joined.
--
on joinList(delimiter, someList)
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to delimiter
set output to "" & someList
set AppleScript's text item delimiters to prevTIDs
return output
end joinList
-- Example
joinList(",", {"a", "b", "c", "d", "e"})
Here’s a two way function. Turn lists into text, and text into lists.
-- If object is a list makes text.
-- If object is text makes a list.
on implode_explode(separator, object)
set {ASTID, my text item delimiters} to {my text item delimiters, {separator}}
if class of object is list then
set object to object as Unicode text
else
set object to text items of object
end if
set my text item delimiters to ASTID
return object --> text or list
end implode_explode
set myList to {"a", "b"}
set mySep to " "
implode_explode(mySep, myList) -->"a b"
set myText to "a b"
set mySep to " "
implode_explode(mySep, myText) -->{"a", "b"}