Seth Woolley's Man Viewer

Manual for read - man n read

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

read(2,n,1 builtins)(n)                      Tcl Built-In Commands                     read(2,n,1 builtins)(n)

       read(2,n,1 builtins) - Read from a channel

       read(2,n,1 builtins) ?-nonewline? channelId

       read(2,n,1 builtins) channelId numChars

       In  the  first  form, the read(2,n,1 builtins) command reads all of the data from chan-
       nelId up to the end of the file.  If the -nonewline switch(1,n) is specified
       then  the  last  character of the file(1,n) is discarded if(3,n) it is a newline.
       In the second form, the extra argument specifies how many characters to
       read.   Exactly  that many characters will be read(2,n,1 builtins) and returned, unless
       there are fewer than numChars left in(1,8) the file(1,n); in(1,8) this  case  all  the
       remaining characters are returned.  If the channel is configured to use
       a multi-byte encoding(3,n), then the number of characters read(2,n,1 builtins)  may  not  be
       the same as the number of bytes read.

       ChannelId  must  be  an  identifier for an open(2,3,n) channel such as the Tcl
       standard input channel (stdin), the return value from an invocation  of
       open(2,3,n) or socket(2,7,n), or the result of a channel creation command provided by
       a Tcl extension. The channel must have been opened for input.

       If channelId is in(1,8) nonblocking mode, the command may not read(2,n,1 builtins)  as  many
       characters  as  requested:  once all available input has been read(2,n,1 builtins), the
       command will return the data that is available rather than blocking for
       more input.  If the channel is configured to use a multi-byte encoding(3,n),
       then there may actually be some bytes remaining in(1,8) the internal buffers
       that  do  not  form  a  complete  character.   These  bytes will not be
       returned until a complete character  is  available  or  end-of-file  is
       reached.   The  -nonewline  switch(1,n)  is  ignored  if(3,n) the command returns
       before reaching the end of the file.

       Read translates end-of-line sequences in(1,8) the input into newline charac-
       ters  according  to  the  -translation option for the channel.  See the
       fconfigure manual entry for a discussion on ways  in(1,8)  which  fconfigure
       will alter input.

       For  most  applications  a channel connected to a serial port should be
       configured to be nonblocking: fconfigure channelId -blocking  0.   Then
       read(2,n,1 builtins)  behaves much like described above.  Care must be taken when using
       read(2,n,1 builtins) on blocking serial ports:

       read(2,n,1 builtins) channelId numChars
              In this form read(2,n,1 builtins) blocks until numChars have been received  from
              the serial port.

       read(2,n,1 builtins) channelId
              In  this form read(2,n,1 builtins) blocks until the reception of the end-of-file
              character, see fconfigure  -eofchar.  If  there  no  end-of-file
              character  has  been  configured for the channel, then read(2,n,1 builtins) will
              block forever.

       file(1,n)(n), eof(n), fblocked(n), fconfigure(n), Tcl_StandardChannels(3)

       blocking, channel, end of line, end of file(1,n), nonblocking, read(2,n,1 builtins),  trans-
       lation, encoding(3,n)

Tcl                                   8.1                              read(2,n,1 builtins)(n)

References for this manual (incoming links)