But I hear what you are saying about list to string. I am having difficulty with it myself.
If it helps at all, I would think about it like this: You need a string to start with, whether it be an empty string ( "" ) or something else, you need a string, as you are, with every item in the list, setting the output to itself + the new item.
(foreach x '("1" "2" "3" "4" "5")
(setq str (strcat str x))
)
If 'str' were nil before the loop, we would have an error, as
(strcat nil "1")
is not valid.
So say, we set 'str' to an empty string:
(setq str "")
(foreach x '("1" "2" "3" "4" "5")
(setq str (strcat str x))
)
Now, with every item, the value of str will be:
x = "1", str = "1"
x = "2", str = "12"
x = "3", str = "123"
etc
We can use this method with a delimiter if need be:
(setq str "")
(foreach x '("1" "2" "3" "4" "5")
(setq str (strcat str x ","))
)
Notice that in this way we receive:
str = "1,2,3,4,5,"
And we have a trailing delimiter on the end - so we can get around this by setting the value of 'str' to the first element in the list instead of the empty string, and iterating through the rest of the list with the delimiter between the existing 'str' and new value:
(setq str "1")
(foreach x '("2" "3" "4" "5")
(setq str (strcat str "," x))
)
x = "2", str = "1,2"
x = "3", str = "1,2,3"
etc
Of course, this is a specific example - so we can replace "," with a variable denoting the delimiter, and use list operations on the list of items:
(setq lst '("1" "2" "3" "4" "5"))
(setq str (car lst) del ",")
(foreach x (cdr lst)
(setq str (strcat str del x))
)
I hope this clarifies things a bit better,
Lee