1mNAME0m
       puts - Write to a channel

1mSYNOPSIS0m
       1mputs 22m?1m-nonewline22m? ?4mchannelId24m? 4mstring0m


1mDESCRIPTION0m
       Writes  the  characters  given  by 4mstring24m to the channel given by 4mchan-0m
       4mnelId24m.

       4mChannelId24m must be an identifier for an open channel such as a Tcl stan-
       dard channel (1mstdout 22mor 1mstderr22m), the return value from an invocation of
       1mopen 22mor 1msocket22m, or the result of a channel creation command provided by
       a Tcl extension. The channel must have been opened for output.

       If  no 4mchannelId24m is specified then it defaults to 1mstdout22m. 1mPuts 22mnormally
       outputs a newline character after 4mstring24m, but this feature may be  sup-
       pressed by specifying the 1m-nonewline 22mswitch.

       Newline  characters  in  the output are translated by 1mputs 22mto platform-
       specific end-of-line sequences according to the current  value  of  the
       1m-translation  22moption  for the channel (for example, on PCs newlines are
       normally replaced with carriage-return-linefeed sequences;   on  Macin-
       toshes  newlines are normally replaced with carriage-returns).  See the
       1mfconfigure 22mmanual entry for a discussion on ways  in  which  1mfconfigure0m
       will alter output.

       Tcl  buffers output internally, so characters written with 1mputs 22mmay not
       appear immediately on the output file or  device;   Tcl  will  normally
       delay  output  until  the buffer is full or the channel is closed.  You
       can force output to appear immediately with the 1mflush 22mcommand.

       When the output buffer fills up, the 1mputs 22mcommand will  normally  block
       until all the buffered data has been accepted for output by the operat-
       ing system.  If 4mchannelId24m is in nonblocking mode then the 1mputs  22mcommand
       will  not  block  even  if the operating system cannot accept the data.
       Instead, Tcl continues to buffer the data and writes it  in  the  back-
       ground  as  fast  as  the underlying file or device can accept it.  The
       application must use the Tcl event loop for nonblocking output to work;
       otherwise Tcl never finds out that the file or device is ready for more
       output data.  It is possible for an arbitrarily large amount of data to
       be  buffered  for  a channel in nonblocking mode, which could consume a
       large amount of memory.   To  avoid  wasting  memory,  nonblocking  I/O
       should  normally  be used in an event-driven fashion with the 1mfileevent0m
       command (don't invoke 1mputs 22munless you have recently been notified via a
       file event that the channel is ready for more output data).

1mEXAMPLES0m
       Write a short message to the console (or wherever 1mstdout 22mis directed):
              1mputs 22m"Hello, World!"

       Print a message in several parts:
              1mputs 22m-nonewline "Hello, "
              1mputs 22m"World!"

       Print a message to the standard error channel:
              1mputs 22mstderr "Hello, World!"

       Append a log message to a file:
              set chan [open my.log a]
              set timestamp [clock format [clock seconds]]
              1mputs 22m$chan "$timestamp - Hello, World!"
              close $chan


1mSEE ALSO0m
       file(n), fileevent(n), Tcl_StandardChannels(3)


1mKEYWORDS0m
