Reputation: 1
How it is possible to join the string from a variable with a list of strings? More exactly, I have this:
set Dir "02_E12_SP_el";
set OutputDir [join {$Dir _ forcesElem21.out} ""];
I want OutputDir
to be "02_E12_SP_el_forcesElem21.out"
, but instead I obtain "$Dir_forcesElem21.out"
Upvotes: 0
Views: 1498
Reputation: 5723
When you wrap a variable in braces {}, it will not be interpreted as a variable.
{$Dir _ forcesElem21.out}
creates a static list.
There are several methods.
The join command concatenates a list of elements together. It is more useful when the list is already built and has the flexibility to specify what to join with (e.g. {, }).
set var 123
set mystr abc
set newstr [join [list $mystr def $var] {}]
Direct concatentation:
set var 123
set mystr abc$var
set mystr ${var}abc
Or the append command:
set var 123
set mystr abc
append mystr $var
Upvotes: 2