Reputation: 573
I want to concatenate two strings without any whitespaces between the strings that are being concatenated. But when I use the commands below, I get strings concatenated with whitespaces added between them. How to concatenate the strings without adding whitespaces?
set A "Test"
set B "data"
set C $A$B
Current Output :
Test data
I need output similar to this :
Testdata
Upvotes: 3
Views: 17288
Reputation: 46
Try using append command
syntax for append is
append var "," $value
#appends value to variable
Without specifying the quotes, the default is null
so,
set A "Test"
set B "data"
append A $B
puts "$A"
The variable contains "Testdata"
Upvotes: 1
Reputation: 81
You can use the Tcl command join.
% set A "Test"
Test
% set B "data"
data
% join [list $A $B] ""
Testdata
Upvotes: 1
Reputation: 11075
If I try that, it works like this:
$ tclsh
% set A "Test"
Test
% set B "data"
data
% set C $A$B
Testdata
Could it be you have accidentally entered some control character between A and $?
Upvotes: 8