{"id":6162,"date":"2022-12-20T18:57:59","date_gmt":"2022-12-20T21:57:59","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/proc-mann\/"},"modified":"2022-12-20T18:57:59","modified_gmt":"2022-12-20T21:57:59","slug":"proc-mann","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/proc-mann\/","title":{"rendered":"proc (mann)"},"content":{"rendered":"<h1 align=\"center\">proc<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/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\">proc \u2212 Create a Tcl procedure<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>proc<\/b> <i>name args body<\/i> ______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>proc<\/b> command creates a new Tcl procedure named <i>name<\/i>, replacing any existing command or procedure there may have been by that name. Whenever the new command is invoked, the contents of <i>body<\/i> will be executed by the Tcl interpreter. Normally, <i>name<\/i> is unqualified (does not include the names of any containing namespaces), and the new procedure is created in the current namespace. If <i>name<\/i> includes any namespace qualifiers, the procedure is created in the specified namespace. <i>Args<\/i> specifies the formal arguments to the procedure. It consists of a list, possibly empty, each of whose elements specifies one argument. Each argument specifier is also a list with either one or two fields. If there is only a single field in the specifier then it is the name of the argument; if there are two fields, then the first is the argument name and the second is its default value. Arguments with default values that are followed by non-defaulted arguments become required arguments; enough actual arguments must be supplied to allow all arguments up to and including the last required formal argument.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">When <i>name<\/i> is invoked a local variable will be created for each of the formal arguments to the procedure; its value will be the value of corresponding argument in the invoking command or the argument\u2019s default value. Actual arguments are assigned to formal arguments strictly in order. Arguments with default values need not be specified in a procedure invocation. However, there must be enough actual arguments for all the formal arguments that do not have defaults, and there must not be any extra actual arguments. Arguments with default values that are followed by non-defaulted arguments become de-facto required arguments, though this may change in a future version of Tcl; portable code should ensure that all optional arguments come after all required arguments.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">There is one special case to permit procedures with variable numbers of arguments. If the last formal argument has the name \u201c<b>args<\/b>\u201d, then a call to the procedure may contain more actual arguments than the procedure has formal arguments. In this case, all of the actual arguments starting at the one that would be assigned to <b>args<\/b> are combined into a list (as if the <b>list<\/b> command had been used); this combined value is assigned to the local variable <b>args<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">When <i>body<\/i> is being executed, variable names normally refer to local variables, which are created automatically when referenced and deleted when the procedure returns. One local variable is automatically created for each of the procedure\u2019s arguments. Other variables can only be accessed by invoking one of the <b>global<\/b>, <b>variable<\/b>, <b>upvar<\/b> or <b>namespace upvar<\/b> commands. The current namespace when <i>body<\/i> is executed will be the namespace that the procedure\u2019s name exists in, which will be the namespace that it was created in unless it has been changed with <b>rename<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>proc<\/b> command returns an empty string. When a procedure is invoked, the procedure\u2019s return value is the value specified in a <b>return<\/b> command. If the procedure does not execute an explicit <b>return<\/b>, then its return value is the value of the last command executed in the procedure\u2019s body. If an error occurs while executing the procedure body, then the procedure-as-a-whole will return that same error.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This is a procedure that takes two arguments and prints both their sum and their product. It also returns the string \u201cOK\u201d to the caller as an explicit result.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>proc<\/b> printSumProduct {x y} { <br \/> set sum [expr {$x + $y}] <br \/> set prod [expr {$x bodies manpages.csv script_extrae_body.sh script.sh usr $y}] <br \/> puts &#8220;sum is $sum, product is $prod&#8221; <br \/> return &#8220;OK&#8221; <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This is a procedure that accepts arbitrarily many arguments and prints them out, one by one.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>proc<\/b> printArguments args { <br \/> foreach arg $args { <br \/> puts $arg <br \/> } <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This procedure is a bit like the <b>incr<\/b> command, except it multiplies the contents of the named variable by the value, which defaults to <b>2<\/b>:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>proc<\/b> mult {varName {multiplier 2}} { <br \/> upvar 1 $varName var <br \/> set var [expr {$var bodies manpages.csv script_extrae_body.sh script.sh usr $multiplier}] <br \/> }<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">info(n), unknown(n)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">argument, procedure<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  proc \u2212 Create a Tcl procedure <\/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":[2635,1482],"class_list":["post-6162","post","type-post","status-publish","format-standard","hentry","category-n-comandos-tcl-tk","category-sin-categoria","tag-mann","tag-proc"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6162","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=6162"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6162\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}