Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

the after command and file buffering

0 views
Skip to first unread message

SYStems

unread,
Aug 6, 2005, 11:58:18 AM8/6/05
to
I was playing and experimenting with file buffering
to I tried the following

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 ......

Uwe Klein

unread,
Aug 6, 2005, 1:09:56 PM8/6/05
to
SYStems wrote:

> #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

suchenwi

unread,
Aug 8, 2005, 4:08:39 AM8/8/05
to
Updating stdout, expecially after [puts -nonewline], best goes with
[flush stdout], of course :)

0 new messages