{"id":6350,"date":"2022-12-20T18:58:12","date_gmt":"2022-12-20T21:58:12","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/eval-mann\/"},"modified":"2022-12-20T18:58:12","modified_gmt":"2022-12-20T21:58:12","slug":"eval-mann","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/eval-mann\/","title":{"rendered":"eval (mann)"},"content":{"rendered":"<h1 align=\"center\">eval<\/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\">eval \u2212 Evaluate a Tcl script<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>eval<\/b> <i>arg<\/i> ?<i>arg &#8230;<\/i>? ______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Eval<\/b> takes one or more arguments, which together comprise a Tcl script containing one or more commands. <b>Eval<\/b> concatenates all its arguments in the same fashion as the <b>concat<\/b> command, passes the concatenated string to the Tcl interpreter recursively, and returns the result of that evaluation (or any error generated by it). Note that the <b>list<\/b> command quotes sequences of words in such a way that they are not further expanded by the <b>eval<\/b> command.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Often, it is useful to store a fragment of a script in a variable and execute it later on with extra values appended. This technique is used in a number of places throughout the Tcl core (e.g. in <b>fcopy<\/b>, <b>lsort<\/b> and <b>trace<\/b> command callbacks). This example shows how to do this using core Tcl commands:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">set script { <br \/> puts &#8220;logging now&#8221; <br \/> lappend $myCurrentLogVar <br \/> } <br \/> set myCurrentLogVar log1 <br \/> # Set up a switch of logging variable part way through! <br \/> after 20000 set myCurrentLogVar log2<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">for {set i 0} {$i<10} {incr i} { <br \/> # Introduce a random delay <br \/> after [expr {int(5000 bodies manpages.csv script_extrae_body.sh script.sh usr rand())}] <br \/> update ;# Check for the asynch log switch <b><br \/> eval<\/b> $script $i [clock clicks] <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Note that in the most common case (where the script fragment is actually just a list of words forming a command prefix), it is better to use <b>{*}$script<\/b> when doing this sort of invocation pattern. It is less general than the <b>eval<\/b> command, and hence easier to make robust in practice. The following procedure acts in a way that is analogous to the <b>lappend<\/b> command, except it inserts the argument values at the start of the list in the variable:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">proc lprepend {varName args} { <br \/> upvar 1 $varName var <br \/> # Ensure that the variable exists and contains a list <br \/> lappend var <br \/> # Now we insert all the arguments in one go <br \/> set var [<b>eval<\/b> [list linsert $var 0] $args] <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">However, the last line would now normally be written without <b>eval<\/b>, like this:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">set var [linsert $var 0 {*}$args]<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">catch(n), concat(n), error(n), errorCode(n), errorInfo(n), interp(n), list(n), namespace(n), subst(n), uplevel(n)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">concatenate, evaluate, script<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  eval \u2212 Evaluate a Tcl script <\/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":[2674,2635],"class_list":["post-6350","post","type-post","status-publish","format-standard","hentry","category-n-comandos-tcl-tk","category-sin-categoria","tag-eval","tag-mann"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6350","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=6350"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6350\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}