Although this isn't quite technically correct, you can think of the Tcl interpreter evaluating each command in the follow steps:
[ol][li]Group the arguments based on whitespace characters and quoting[/li][li]Perform all substitutions[/li][li]Execute the result, using the first "word" as the command to execute, passing all of the following words as arguments to the command[/li][/ol]
In your example, the Tcl interpreter regards "$myList" as a single argument, which happens to contain whitespace characters after the substitution is performed. Thus, the value of
myList (for example, "jim.txt bob.txt tim.txt"

gets passed as a single argument to
exec, which passed it as a single argument to
wordpad.exe when it executes that program.
To solve this problem, you're going to need to use another Tcl command called
eval, which concatenates all of its arguments together (just like the
concat command), and then executes the result. In this example, the following should work correctly:
Code:
eval exec wordpad.exe $myList
When
eval executes, it see 3 arguments: "exec", "wordpad.exe" and the value of
myList, let's say "jim.txt bob.txt tim.txt". Then then concatenates these arguments together into something that in this case would look like:
Code:
exec wordpad.exe jim.txt bob.txt tim.txt
eval then executes this result, which is what you wanted.
- Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
408-983-1199 Voice
408-983-1198 Fax