instead of using a global variable you should use a local i.e. use /var instead of /set which removes the need to unset all the varibles at the end
also you can use $regsubex to make this significantly smaller/faster
alias secret { echo -a Result: //echo $+($!+,$chr(40),,$regsubex($$1-,/(.)/g,$+($!chr,$chr(40),$asc(\t),$chr(41),$iif(\n != \0,$chr(44),$chr(41))))) }