问题是链接中回答的内容的扩展。在尝试使用它延迟打印输出时,cat file_name在 shell 上使用after. 这是代码:
proc foo {times} {
while {$times >0} {
puts "hello$times"
incr times -1
after 20000
puts "hello world"
}
}
proc reopenStdout {file} {
close stdout
open $file w ;# The standard channels are special
}
reopenStdout ./bar
foo 10