Reputation: 3267
I have the following code in tcl:
set string1 "do the firstthing"
set string2 "do the secondthing"
how to make a combine two strings to have "do the firstthing do the secondthing"
Upvotes: 4
Views: 23699
Reputation: 1007
Use the append command:
set string1 "do the firstthing"
set string2 "do the secondthing"
append var $string1 "," $string2
puts $var
# Prints do the firstthing,do the secondthing
Upvotes: 1
Reputation: 71538
You can use append
like this:
% set string1 "do the firstthing"
% set string2 "do the secondthing"
% append string1 " " $string2
% puts $string1
do the firstthing do the secondthing
You can put them next to the other...
% set string1 "do the firstthing"
% set string2 "do the secondthing"
% puts "$string1 $string2"
do the firstthing do the secondthing
Or if your strings are in a list, you can use join
and specify the connector...
% set listofstrings [list "do the firstthing" "do the secondthing"]
% puts [join $listofthings " "]
do the firstthing do the secondthing
Upvotes: 8
Reputation:
String concatenation in tcl is just juxtaposition
set result "$string1$string2"
set result $string1$string
Upvotes: 6