Version 3 of flush

Updated 2007-01-28 13:36:40

flush - Flush buffered output for a channel http://www.purl.org/tcl/home/man/tcl8.4/TclCmd/flush.htm

 flush channelId  

Flushes any output that has been buffered for channelId. ChannelId must be a channel identifier such as returned by a previous open or socket command, and it must have been opened for writing. If the channel is in blocking mode the command does not return until all the buffered output has been flushed to the channel. If the channel is in nonblocking mode, the command may return before all buffered output has been flushed; the remainder will be flushed in the background as fast as the underlying file or device is able to absorb it. (From: TclHelp)


Cases in which flushing is a good idea:

  • puts -nonewline'ing a string, e.g.,
        puts -nonewline "Enter value: "
        flush stdout
        set result [gets stdin]
  • when using unnamed pipe IPC

Tcl syntax help - Arts and crafts of Tcl-Tk programming

[ Category Command from Tcl | Category Channel ]