{"id":6269,"date":"2022-12-20T18:58:05","date_gmt":"2022-12-20T21:58:05","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/variable-mann\/"},"modified":"2022-12-20T18:58:05","modified_gmt":"2022-12-20T21:58:05","slug":"variable-mann","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/variable-mann\/","title":{"rendered":"variable (mann)"},"content":{"rendered":"<h1 align=\"center\">variable<\/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\">variable \u2212 create and initialize a namespace variable<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>variable<\/b> <i>name<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>variable<\/b> ?<i>name value&#8230;<\/i>? ______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This command is normally used within a <b>namespace eval<\/b> command to create one or more variables within a namespace. Each variable <i>name<\/i> is initialized with <i>value<\/i>. The <i>value<\/i> for the last variable is optional.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If a variable <i>name<\/i> does not exist, it is created. In this case, if <i>value<\/i> is specified, it is assigned to the newly created variable. If no <i>value<\/i> is specified, the new variable is left undefined. If the variable already exists, it is set to <i>value<\/i> if <i>value<\/i> is specified or left unchanged if no <i>value<\/i> is given. Normally, <i>name<\/i> is unqualified (does not include the names of any containing namespaces), and the variable is created in the current namespace. If <i>name<\/i> includes any namespace qualifiers, the variable is created in the specified namespace. If the variable is not defined, it will be visible to the <b>namespace which<\/b> command, but not to the <b>info exists<\/b> command.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If the <b>variable<\/b> command is executed inside a Tcl procedure, it creates local variables linked to the corresponding namespace variables (and therefore these variables are listed by <b>info vars<\/b>.) In this way the <b>variable<\/b> command resembles the <b>global<\/b> command, although the <b>global<\/b> command resolves variable names with respect to the global namespace instead of the current namespace of the procedure. If any <i>value<\/i>s are given, they are used to modify the values of the associated namespace variables. If a namespace variable does not exist, it is created and optionally initialized.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">A <i>name<\/i> argument cannot reference an element within an array. Instead, <i>name<\/i> should reference the entire array, and the initialization <i>value<\/i> should be left off. After the variable has been declared, elements within the array can be set using ordinary <b>set<\/b> or <b>array<\/b> commands.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Create a variable in a namespace:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">namespace eval foo { <b><br \/> variable<\/b> bar 12345 <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Create an array in a namespace:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">namespace eval someNS { <b><br \/> variable<\/b> someAry <br \/> array set someAry { <br \/> someName someValue <br \/> otherName otherValue <br \/> } <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Access variables in namespaces from a procedure:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">namespace eval foo { <br \/> proc spong {} { <br \/> # Variable in this namespace <b><br \/> variable<\/b> bar <br \/> puts &#8220;bar is $bar&#8221;<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"># Variable in another namespace <b><br \/> variable<\/b> ::someNS::someAry <br \/> parray someAry <br \/> } <br \/> }<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">global(n), namespace(n), upvar(n)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">global, namespace, procedure, variable<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  variable \u2212 create and initialize a namespace variable <\/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,2881],"class_list":["post-6269","post","type-post","status-publish","format-standard","hentry","category-n-comandos-tcl-tk","category-sin-categoria","tag-mann","tag-variable"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6269","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=6269"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6269\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}