This should wait 20 seconds then print 20 dots
<code>
# example 1
for {set x 0} {$x<20} {incr x} {
after 1000
puts -nonewline ". "
}
puts ""
</code>
And this should wait a second, print a dot, 20 times ...
<code>
#example 2
fconfigure stdout -buffering none
for {set x 0} {$x<20} {incr x} {
after 1000
puts -nonewline ". "
}
puts ""
</code>
I expected this to act like example 1, wait 20 seconds then print 20
dots
<code>
#example 3
for {set x 0} {$x<20} {incr x} {
after 1000 [list puts -nonewline ". "]
}
puts ""
</code>
But instead it just printed a new line, the question is why?
I don't get ...
Hmmm ......
> #example 3
>
> for {set x 0} {$x<20} {incr x} {
> after 1000 [list puts -nonewline ". "]
>
> }
>
> puts ""
> </code>
you now have queued 20 events and put one newline to the console
tclsh is waiting for more input from you and has therefore no chance
to process the events.
try [update] or [vwait]
look here http://wiki.tcl.tk/2567
uwe