read(3tcl)


NAME

   read - Read from a channel

SYNOPSIS

   read ?-nonewline? channelId

   read channelId numChars
______________________________________________________________________________

DESCRIPTION

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

   ChannelId  must  be  an  identifier for an open channel such as the Tcl
   standard input channel (stdin), the return value from an invocation  of
   open or socket, 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 nonblocking mode, the command may not read  as  many
   characters  as  requested:  once all available input has been read, 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,
   then there may actually be some bytes remaining in 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  is  ignored  if the command returns
   before reaching the end of the file.

   Read  translates  end-of-line  sequences  in  the  input  into  newline
   characters  according  to the -translation option for the channel.  See
   the  fconfigure  manual  entry  for  a  discussion  on  ways  in  which
   fconfigure will alter input.

USE WITH SERIAL PORTS

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

   read channelId numChars
          In this form read blocks until numChars have been received  from
          the serial port.

   read channelId
          In  this form read 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 will
          block forever.

EXAMPLE

   This example code reads a file all at once, and splits it into a  list,
   with each line in the file corresponding to an element in the list:
          set fl [open /proc/meminfo]
          set data [read $fl]
          close $fl
          set lines [split $data \n]

SEE ALSO

   file(3tcl),      eof(3tcl),      fblocked(3tcl),      fconfigure(3tcl),
   Tcl_StandardChannels(3tcl)

KEYWORDS

   blocking, channel,  end  of  line,  end  of  file,  nonblocking,  read,
   translation, encoding





Opportunity


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.





Free Software


Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.


Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.





Free Books


The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.


Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.





Education


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.


Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.