Reputation: 1
In TCL, when joining a list on a carriage return like so:
set myList {{a} {b} {c} {d} {e} {f} {g}}
puts [join $myList \r]
The output printed to the screen is:
g
If I instead do the following:
set myList {{a} {b} {c} {d} {e} {f} {g}}
puts [join $myList \n]
The output is
a
b
c
d
e
f
g
What makes the use carriage return "\r" in the join only produce "g" while the use of newline "\n" gives me everything in the list?
Upvotes: 0
Views: 456
Reputation: 71598
This has more to do with the output than with Tcl join
. Your output (a console/shell for example) may not be able to display carriage return.
For instance, if you do:
set myList {{a} {b} {c} {d} {e} {f} {g}}
set result [join $myList \r]
puts [string length $result]
You get 13 as the output, showing that the string is correct.
If you can change the output location to a text file for example, and then open the file in an editor that can recognize carriage return as a character that denotes a change in line (I used notepad++ to test), you'll see the output is fine.
Upvotes: 1