<HTML><HEAD><TITLE>Tcl Built-In Commands - gets manual page</TITLE></HEAD><BODY> <H3><A NAME="M2">NAME</A></H3> gets - Read a line from a channel <H3><A NAME="M3">SYNOPSIS</A></H3> <B>gets </B><I>channelId</I> ?<I>varName</I>?<BR> <H3><A NAME="M4">DESCRIPTION</A></H3> This command reads the next line from <I>channelId</I>, returns everything in the line up to (but not including) the end-of-line character(s), and discards the end-of-line character(s). If <I>varName</I> is omitted the line is returned as the result of the command. If <I>varName</I> is specified then the line is placed in the variable by that name and the return value is a count of the number of characters returned. <P> If end of file occurs while scanning for an end of line, the command returns whatever input is available up to the end of file. If <I>channelId</I> is in nonblocking mode and there is not a full line of input available, the command returns an empty string and does not consume any input. If <I>varName</I> is specified and an empty string is returned in <I>varName</I> because of end-of-file or because of insufficient data in nonblocking mode, then the return count is -1. Note that if <I>varName</I> is not specified then the end-of-file and no-full-line-available cases can produce the same results as if there were an input line consisting only of the end-of-line character(s). The <B><A HREF="../TkCmd/eof.htm">eof</A></B> and <B><A HREF="../TkCmd/fblocked.htm">fblocked</A></B> commands can be used to distinguish these three cases. <H3><A NAME="M5">SEE ALSO</A></H3> <B><A HREF="../TkCmd/file.htm">file</A></B>, <B><A HREF="../TkCmd/eof.htm">eof</A></B>, <B><A HREF="../TkCmd/fblocked.htm">fblocked</A></B> <H3><A NAME="M6">KEYWORDS</A></H3> <A href="../Keywords/B.htm#blocking">blocking</A>, <A href="../Keywords/C.htm#channel">channel</A>, <A href="../Keywords/E.htm#end of file">end of file</A>, <A href="../Keywords/E.htm#end of line">end of line</A>, <A href="../Keywords/L.htm#line">line</A>, <A href="../Keywords/N.htm#nonblocking">nonblocking</A>, <A href="../Keywords/R.htm#read">read</A> <HR><PRE> <A HREF="../copyright.htm">Copyright</A> © 1993 The Regents of the University of California. <A HREF="../copyright.htm">Copyright</A> © 1994-1996 Sun Microsystems, Inc. <A HREF="../copyright.htm">Copyright</A> © 1995-1997 Roger E. Critchlow Jr.</PRE> </BODY></HTML>