如何在同一行重复打印某些内容?也就是说,在某个过程完成之前使用百分比递减计数器?我希望xterm行上的百分比数字在不滚动的情况下倒计时。
如果我做
puts -nonewline "10%"
puts -nonewline "9%"
puts -nonewline "8%"
puts -nonewline "7%"
我得到:
10%9%8%7%....
这看起来不对。
怎么回事?
谢谢,Gert
您想要回车将光标发送到行的开头:
for {set i 10} {$i>0} {incr i -1} {
puts -nonewline [format "r%2d%%" $i]
flush stdout
after 200
}; puts ""