Seth Woolley's Man Viewer

fconfigure(n) - fconfigure, fconfigure - Set and get options on a channel - man n fconfigure

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

fconfigure(n)                Tcl Built-In Commands               fconfigure(n)

       fconfigure - Set and get options on a channel

       fconfigure channelId
       fconfigure channelId name
       fconfigure channelId name value ?name value ...?

       The fconfigure command sets and retrieves options for channels.

       ChannelId  identifies  the  channel for which to set(7,n,1 builtins) or query an option
       and must refer to an open(2,3,n)  channel  such  as  a  Tcl  standard  channel
       (stdin, stdout, or stderr), 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.

       If  no name or value arguments are supplied, the command returns a list
       containing alternating option names and values  for  the  channel.   If
       name  is  supplied  but  no  value then the command returns the current
       value of the given option.  If one or more pairs of name and value  are
       supplied, the command sets each of the named(5,8) options to the correspond-
       ing value; in(1,8) this case the return value is an empty string.

       The options described below are supported for all  channels.  In  addi-
       tion,  each channel type may add options that only it supports. See the
       manual entry for the command that creates each type of channels for the
       options  that  that specific type of channel supports. For example, see
       the manual entry for the socket(2,7,n) command for its additional options.

       -blocking boolean
              The -blocking option determines whether I/O  operations  on  the
              channel  can cause the process to block indefinitely.  The value
              of the option must be a proper boolean value.  Channels are nor-
              mally in(1,8) blocking mode;  if(3,n) a channel is placed into nonblocking
              mode it will affect the  operation  of  the  gets(3,n),  read(2,n,1 builtins),  puts(3,n),
              flush(8,n),  and close(2,7,n) commands; see the documentation for those com-
              mands for details.  For nonblocking mode to work correctly,  the
              application  must  be  using the Tcl event loop (e.g. by calling
              Tcl_DoOneEvent or invoking the vwait command).

       -buffering newValue
              If newValue is full then the I/O system will buffer output until
              its  internal  buffer  is  full  or  until  the flush(8,n) command is
              invoked. If newValue is line, then the I/O system will automati-
              cally  flush(8,n) output for the channel whenever a newline character
              is output. If newValue is none, the I/O system will flush(8,n)  auto-
              matically  after  every  output  operation.   The default is for
              -buffering to be set(7,n,1 builtins) to full except for channels that connect to
              terminal-like devices; for these channels the initial setting is
              line.  Additionally, stdin and stdout are initially set(7,n,1 builtins) to line,
              and stderr is set(7,n,1 builtins) to none.

       -buffersize newSize
              Newvalue  must  be an integer; its value is used to set(7,n,1 builtins) the size
              of buffers, in(1,8) bytes, subsequently allocated for this channel to
              store input or output. Newvalue must be between ten and one mil-
              lion, allowing buffers of ten to one million bytes in(1,8) size.

       -encoding name
              This option is used to specify the encoding(3,n) of the  channel,  so
              that  the  data  can be converted to and from Unicode for use in(1,8)
              Tcl.  For instance, in(1,8) order for Tcl to read(2,n,1 builtins) characters  from  a
              Japanese  file(1,n)  in(1,8) shiftjis and properly process and display the
              contents, the encoding(3,n) would be set(7,n,1 builtins)  to  shiftjis.   Thereafter,
              when  reading  from  the channel, the bytes in(1,8) the Japanese file(1,n)
              would be converted to Unicode as they are read.  Writing is also
              supported  - as Tcl strings are written to the channel they will
              automatically be converted to the specified encoding(3,n) on  output.

              If  a  file(1,n)  contains  pure  binary  data  (for instance, a JPEG
              image), the encoding(3,n) for the channel should be configured to  be
              binary.   Tcl  will then assign no interpretation to the data in(1,8)
              the file(1,n) and simply read(2,n,1 builtins) or write(1,2) raw(3x,7,8,3x cbreak)  bytes.   The  Tcl  binary
              command can be used to manipulate this byte-oriented data.

              The default encoding(3,n) for newly opened channels is the same plat-
              form- and locale-dependent system encoding(3,n) used for  interfacing
              with the operating system.

       -eofchar char

       -eofchar {inChar outChar}
              This  option supports DOS file(1,n) systems that use Control-z (\x1a)
              as an end of file(1,n) marker.  If char is not an empty string(3,n),  then
              this character signals end-of-file when it is encountered during
              input.  For output, the end-of-file character is output when the
              channel  is  closed.  If char is the empty string(3,n), then there is
              no special end of file(1,n) character marker.  For  read-write  chan-
              nels,  a  two-element  list specifies the end of file(1,n) marker for
              input and output, respectively.  As a convenience, when  setting
              the end-of-file character for a read-write channel you can spec-
              ify a single value that will apply to both reading and  writing.
              When querying the end-of-file character of a read-write channel,
              a two-element list will always be returned.  The  default  value
              for  -eofchar  is the empty string(3,n) in(1,8) all cases except for files
              under Windows.  In that case the -eofchar  is  Control-z  (\x1a)
              for reading and the empty string(3,n) for writing.

       -translation mode

       -translation {inMode outMode}
              In  Tcl  scripts the end of a line is always represented using a
              single newline character (\n).  However,  in(1,8)  actual  files  and
              devices the end of a line may be represented differently on dif-
              ferent platforms, or even for  different  devices  on  the  same
              platform.   For  example, under UNIX newlines are used in(1,8) files,
              whereas carriage-return-linefeed sequences are normally used  in(1,8)
              network  connections.   On  input (i.e., with gets(3,n) and read(2,n,1 builtins)) the
              Tcl I/O system automatically translates the external end-of-line
              representation into newline characters.  Upon output (i.e., with
              puts(3,n)), the I/O system translates newlines to the  external  end-
              of-line  representation.   The  default  translation mode, auto(5,8),
              handles all the common cases automatically, but the -translation
              option  provides  explicit control over the end of line transla-

              The value associated with -translation  is  a  single  item  for
              read-only  and  write-only channels.  The value is a two-element
              list for read-write channels; the read(2,n,1 builtins) translation mode  is  the
              first element of the list, and the write(1,2) translation mode is the
              second element.  As a convenience, when setting the  translation
              mode  for  a  read-write  channel you can specify a single value
              that will apply to both reading and writing.  When querying  the
              translation  mode  of  a  read-write channel, a two-element list
              will always be returned.  The  following  values  are  currently

              auto(5,8)   As the input translation mode, auto(5,8) treats any of newline
                     (lf), carriage return (cr), or carriage  return  followed
                     by  a  newline  (crlf) as the end of line representation.
                     The end of line representation can even change from line-
                     to-line,  and  all cases are translated to a newline.  As
                     the output translation mode, auto(5,8) chooses a platform spe-
                     cific  representation;  for  sockets on all platforms Tcl
                     chooses crlf, for all Unix flavors, it  chooses  lf,  for
                     the  Macintosh platform it chooses cr and for the various
                     flavors of Windows it chooses crlf.  The default  setting
                     for -translation is auto(5,8) for both input and output.

              binary No  end-of-line  translations  are  performed.   This  is
                     nearly identical to lf  mode,  except  that  in(1,8)  addition
                     binary  mode  also  sets the end-of-file character to the
                     empty string(3,n) (which disables it) and sets the encoding(3,n) to
                     binary  (which  disables  encoding(3,n)  filtering).   See the
                     description of -eofchar and -encoding for  more  informa-

              cr     The  end  of  a  line in(1,8) the underlying file(1,n) or device is
                     represented by a single carriage  return  character.   As
                     the  input  translation  mode,  cr mode converts carriage
                     returns to newline characters.  As the output translation
                     mode,  cr  mode translates newline characters to carriage
                     returns.  This mode is typically used on Macintosh  plat-

              crlf   The  end  of  a  line in(1,8) the underlying file(1,n) or device is
                     represented by a carriage return character followed by  a
                     linefeed  character.  As the input translation mode, crlf
                     mode converts carriage-return-linefeed sequences to  new-
                     line  characters.   As  the output translation mode, crlf
                     mode translates newline  characters  to  carriage-return-
                     linefeed  sequences.  This mode is typically used on Win-
                     dows platforms and for network connections.

              lf     The end of a line in(1,8) the underlying  file(1,n)  or  device  is
                     represented by a single newline (linefeed) character.  In
                     this mode no translations occur during  either  input  or
                     output.  This mode is typically used on UNIX platforms.

       The Tcl standard channels (stdin, stdout, and stderr) can be configured
       through this command  like  every  other  channel  opened  by  the  Tcl
       library.  Beyond  the  standard  options described above they will also
       support any special option according to their current  type.   If,  for
       example,  a  Tcl application is started by the inet super-server common
       on Unix system its Tcl standard channels will be sockets and thus  sup-
       port the socket(2,7,n) options.

       close(2,7,n)(n),  flush(8,n)(n),  gets(3,n)(n),  open(2,3,n)(n),  puts(3,n)(n),  read(2,n,1 builtins)(n), socket(2,7,n)(n),

       blocking, buffering, carriage return, end of line, flushing,  linemode,
       newline,  nonblocking,  platform,  translation,  encoding(3,n), filter(1,3x,3x curs_util), byte
       array, binary

Tcl                                   8.3                        fconfigure(n)

References for this manual (incoming links)