i tend to avoid replacing with $chr(160), especially when it isn't necessary. the only problem here is that single trailing spaces in variables are cut off, but there's no problem with handling any amounts of spaces anywhere else, so looping backwards solves the problem:
test {
var %x = $len($1-), %toSend
while (%x) {
set -n %toSend $mid($1-,%x,1) $+ %toSend
dec %x
}
echo -a say %toSend
}
you should get into the habit of using /set's -n switch when you're handling any arbitrary piece of text (in case of /test 1 + 1 or such)
another method i've seen is to append $chr(32) each iteration, so similar to your original code but that middle line becomes:
set -n %toSend $+(%toSend,$mid($1-,%x,1),$chr(32))
this relies on the fact that a single trailing space will be stripped. so whenever $mid($1-,%x,1) != $chr(32), that space will be eaten up. of course, if it does == $chr(32), both spaces are retained.. so at the end of the loop you'll have 2 spaces for every single space in %toSend. if you pass this to a command (like /say) those excess spaces are stripped and there'll be no difference