How to concatenate strings in TCL without adding whitespace

14,747

Solution 1

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 $?

Solution 2

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"

Share:
14,747
user1270123
Author by

user1270123

Updated on June 28, 2022

Comments

  • user1270123
    user1270123 almost 2 years

    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