title: How to add a variable amount of arguments to exec in tcl?
body: <p>I've been working with TCL for some time now, and I have spent a long time trying to do the following (it seems easy and I think it should be, but I can't get it right):</p>
  
  <p>I need to execute an external program by means of a tcl script. For that, I use the <code>exec</code> command. For using this external program, I need to input a variable amount of files. If I called this program straight from a cmd window, it would be something like:</p>
  
  <pre><code>C:\&gt;myprogram -i file1 -i file2 -i file3 (etc., etc.)
  </code></pre>
  
  <p>However, when trying to implement this in a dynamic/variable way through tcl I get into trouble. The way I do it is by storing in some variable myvar all the "<code>-i filex</code>" I need (done in a loop), and then pass that as a parameter to the <code>exec</code> command. It would look something like:</p>
  
  <pre><code>exec myprogram $myvar
  </code></pre>
  
  <p>Doing that apparently creates some issues, because this myprogram fails to "see" myvar. I'm guessing that there is some sort of hidden terminator or some clash of different types of arguments that makes that in the end the exec command "sees" only myprogram.</p>
  
  <p>So, my question is, does anyone know how to insert variable arguments into a call to <code>exec</code>?</p>