{"id":6198,"date":"2022-12-20T18:58:01","date_gmt":"2022-12-20T21:58:01","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/gets-mann\/"},"modified":"2022-12-20T18:58:01","modified_gmt":"2022-12-20T21:58:01","slug":"gets-mann","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/gets-mann\/","title":{"rendered":"gets (mann)"},"content":{"rendered":"<h1 align=\"center\">gets<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#EXAMPLE\">EXAMPLE<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#KEYWORDS\">KEYWORDS<\/a> <\/p>\n<hr>\n<p>______________________________________________________________________________<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">gets \u2212 Read a line from a channel<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>gets<\/b> <i>channelId<\/i> ?<i>varName<\/i>? ______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">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).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>ChannelId<\/i> must be an identifier for an open channel such as the Tcl standard input channel (<b>stdin<\/b>), the return value from an invocation of <b>open<\/b> or <b>socket<\/b>, or the result of a channel creation command provided by a Tcl extension. The channel must have been opened for input.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">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>\n<p style=\"margin-left:11%; margin-top: 1em\">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 non-blocking 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 non-blocking 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>eof<\/b> and <b>fblocked<\/b> commands can be used to distinguish these three cases.<\/p>\n<h2>EXAMPLE <a name=\"EXAMPLE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This example reads a file one line at a time and prints it out with the current line number attached to the start of each line.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">set chan [open &#8220;some.file.txt&#8221;] <br \/> set lineNumber 0 <br \/> while {[<b>gets<\/b> $chan line] >= 0} { <br \/> puts &#8220;[incr lineNumber]: $line&#8221; <br \/> } <br \/> close $chan<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">file(n), eof(n), fblocked(n), Tcl_StandardChannels(3)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">blocking, channel, end of file, end of line, line, non-blocking, read<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  gets \u2212 Read a line from a channel <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3783,1],"tags":[2055,2635],"class_list":["post-6198","post","type-post","status-publish","format-standard","hentry","category-n-comandos-tcl-tk","category-sin-categoria","tag-gets","tag-mann"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=6198"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6198\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}