TCL特殊字符\ x1

时间:2016-10-25 16:04:15

标签: tcl

我的TCL字符串有问题

set WORD 128
set CELL_NAME "MCELL_$WORD\x1" 

# real: MCELL_128.. (.. is 2 special characters that I can't paste here)

# expected: "MCELL_128x1"

如何按预期格式化字符串?

1 个答案:

答案 0 :(得分:2)

set CELL_NAME "MCELL_${WORD}x1"

为您提供预期的输出。

其他可能性:

set CELL_NAME "MCELL_[set WORD]x1"
set CELL_NAME [format "MCELL_%dx1" $WORD]

文档: formatsetSummary of Tcl language syntax,特别是[8]项。