tcltcltk

Tcl/Tk : Passing variable no. of arguments within tcl code


set newarg [join $argmnts " "] 
set msg [exec $fname arguments] 

Note : argmnts are not commandline arguments, it is from value_dialog_box

newarg is a list of arguments (no. of arguments may vary in newarg), fname is some file name. I want to pass these arguments (newarg) in [exec $fname arguments]

how can i do that ?


Solution

  • You're looking for argument expansion:

    set msg [exec $fname {*}$argmnts]
    

    which treats the elements of the list in $argmnts as individual arguments to exec.