{"id":7370,"date":"2022-12-20T19:37:51","date_gmt":"2022-12-20T22:37:51","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/tcl_eval-man3-3\/"},"modified":"2022-12-20T19:37:51","modified_gmt":"2022-12-20T22:37:51","slug":"tcl_eval-man3-3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/tcl_eval-man3-3\/","title":{"rendered":"Tcl_Eval (man3)"},"content":{"rendered":"<h1 align=\"center\">Tcl_Eval<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#ARGUMENTS\">ARGUMENTS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#FLAG BITS\">FLAG BITS<\/a><br \/> <a href=\"#MISCELLANEOUS DETAILS\">MISCELLANEOUS DETAILS<\/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\">Tcl_EvalObjEx, Tcl_EvalFile, Tcl_EvalObjv, Tcl_Eval, Tcl_EvalEx, Tcl_GlobalEval, Tcl_GlobalEvalObj, Tcl_VarEval, Tcl_VarEvalVA \u2212 execute Tcl scripts<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <tcl.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <b><br \/> Tcl_EvalObjEx<\/b>(<i>interp, objPtr, flags<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <b><br \/> Tcl_EvalFile<\/b>(<i>interp, fileName<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <b><br \/> Tcl_EvalObjv<\/b>(<i>interp, objc, objv, flags<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <b><br \/> Tcl_Eval<\/b>(<i>interp, script<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <b><br \/> Tcl_EvalEx<\/b>(<i>interp, script, numBytes, flags<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <b><br \/> Tcl_GlobalEval<\/b>(<i>interp, script<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <b><br \/> Tcl_GlobalEvalObj<\/b>(<i>interp, objPtr<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <b><br \/> Tcl_VarEval<\/b>(<i>interp, part, part, &#8230;<\/i> <b>(char *) NULL<\/b>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <b><br \/> Tcl_VarEvalVA<\/b>(<i>interp, argList<\/i>)<\/p>\n<h2>ARGUMENTS <a name=\"ARGUMENTS\"><\/a> <\/h2>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"38%\">\n<p style=\"margin-top: 1em\">Tcl_Interp <i>*interp<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"35%\">\n<p style=\"margin-top: 1em\">Interpreter in which to execute the script. The interpreter\u2019s result is modified to hold the result or error message from the script.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"38%\">\n<p>Tcl_Obj <i>*objPtr<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"35%\">\n<p>A Tcl value containing the script to execute.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"38%\">\n<p>int <i>flags<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"35%\">\n<p>ORed combination of flag bits that specify additional options. <b>TCL_EVAL_GLOBAL<\/b> and <b>TCL_EVAL_DIRECT<\/b> are currently supported.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"38%\">\n<p>const char <i>*fileName<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"35%\">\n<p>Name of a file containing a Tcl script.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"38%\">\n<p>int <i>objc<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"35%\">\n<p>The number of values in the array pointed to by <i>objPtr<\/i>; this is also the number of words in the command.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"38%\">\n<p>Tcl_Obj <i>**objv<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"35%\">\n<p>Points to an array of pointers to values; each value holds the value of a single word in the command to execute.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"38%\">\n<p>int <i>numBytes<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"35%\">\n<p>The number of bytes in <i>script<\/i>, not including any null terminating character. If \u22121, then all characters up to the first null byte are used.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"38%\">\n<p>const char <i>*script<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"35%\">\n<p>Points to first byte of script to execute (null-terminated and UTF-8).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"38%\">\n<p>char <i>*part<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"35%\">\n<p>String forming part of a Tcl script.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"38%\">\n<p>va_list <i>argList<\/i> (in)<\/p>\n<\/td>\n<td width=\"16%\"><\/td>\n<td width=\"35%\">\n<p>An argument list which must have been initialized using <b>va_start<\/b>, and cleared using <b>va_end<\/b>.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:65%;\">______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The procedures described here are invoked to execute Tcl scripts in various forms. <b>Tcl_EvalObjEx<\/b> is the core procedure and is used by many of the others. It executes the commands in the script stored in <i>objPtr<\/i> until either an error occurs or the end of the script is reached. If this is the first time <i>objPtr<\/i> has been executed, its commands are compiled into bytecode instructions which are then executed. The bytecodes are saved in <i>objPtr<\/i> so that the compilation step can be skipped if the value is evaluated again in the future.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The return value from <b>Tcl_EvalObjEx<\/b> (and all the other procedures described here) is a Tcl completion code with one of the values <b>TCL_OK<\/b>, <b>TCL_ERROR<\/b>, <b>TCL_RETURN<\/b>, <b>TCL_BREAK<\/b>, or <b>TCL_CONTINUE<\/b>, or possibly some other integer value originating in an extension. In addition, a result value or error message is left in <i>interp<\/i>\u2019s result; it can be retrieved using <b>Tcl_GetObjResult<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_EvalFile<\/b> reads the file given by <i>fileName<\/i> and evaluates its contents as a Tcl script. It returns the same information as <b>Tcl_EvalObjEx<\/b>. If the file could not be read then a Tcl error is returned to describe why the file could not be read. The eofchar for files is \u201c32\u201d (^Z) for all platforms. If you require a \u201c^Z\u201d in code for string comparison, you can use \u201c\u000032\u201d or \u201cu001a\u201d, which will be safely substituted by the Tcl interpreter into \u201c^Z\u201d.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_EvalObjv<\/b> executes a single pre-parsed command instead of a script. The <i>objc<\/i> and <i>objv<\/i> arguments contain the values of the words for the Tcl command, one word in each value in <i>objv<\/i>. <b>Tcl_EvalObjv<\/b> evaluates the command and returns a completion code and result just like <b>Tcl_EvalObjEx<\/b>. The caller of <b>Tcl_EvalObjv<\/b> has to manage the reference count of the elements of <i>objv<\/i>, insuring that the values are valid until <b>Tcl_EvalObjv<\/b> returns.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_Eval<\/b> is similar to <b>Tcl_EvalObjEx<\/b> except that the script to be executed is supplied as a string instead of a value and no compilation occurs. The string should be a proper UTF-8 string as converted by <b>Tcl_ExternalToUtfDString<\/b> or <b>Tcl_ExternalToUtf<\/b> when it is known to possibly contain upper ASCII characters whose possible combinations might be a UTF-8 special code. The string is parsed and executed directly (using <b>Tcl_EvalObjv<\/b>) instead of compiling it and executing the bytecodes. In situations where it is known that the script will never be executed again, <b>Tcl_Eval<\/b> may be faster than <b>Tcl_EvalObjEx<\/b>. <b><br \/> Tcl_Eval<\/b> returns a completion code and result just like <b>Tcl_EvalObjEx<\/b>. Note: for backward compatibility with versions before Tcl 8.0, <b>Tcl_Eval<\/b> copies the value result in <i>interp<\/i> to <i>interp->result<\/i> (use is deprecated) where it can be accessed directly. <br \/> This makes <b>Tcl_Eval<\/b> somewhat slower than <b>Tcl_EvalEx<\/b>, which does not do the copy.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_EvalEx<\/b> is an extended version of <b>Tcl_Eval<\/b> that takes additional arguments <i>numBytes<\/i> and <i>flags<\/i>. For the efficiency reason given above, <b>Tcl_EvalEx<\/b> is generally preferred over <b>Tcl_Eval<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_GlobalEval<\/b> and <b>Tcl_GlobalEvalObj<\/b> are older procedures that are now deprecated. They are similar to <b>Tcl_EvalEx<\/b> and <b>Tcl_EvalObjEx<\/b> except that the script is evaluated in the global namespace and its variable context consists of global variables only (it ignores any Tcl procedures that are active). These functions are equivalent to using the <b>TCL_EVAL_GLOBAL<\/b> flag (see below).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_VarEval<\/b> takes any number of string arguments of any length, concatenates them into a single string, then calls <b>Tcl_Eval<\/b> to execute that string as a Tcl command. It returns the result of the command and also modifies <i>interp->result<\/i> in the same way as <b>Tcl_Eval<\/b>. The last argument to <b>Tcl_VarEval<\/b> must be NULL to indicate the end of arguments. <b>Tcl_VarEval<\/b> is now deprecated.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_VarEvalVA<\/b> is the same as <b>Tcl_VarEval<\/b> except that instead of taking a variable number of arguments it takes an argument list. Like <b>Tcl_VarEval<\/b>, <b>Tcl_VarEvalVA<\/b> is deprecated.<\/p>\n<h2>FLAG BITS <a name=\"FLAG BITS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Any ORed combination of the following values may be used for the <i>flags<\/i> argument to procedures such as <b>Tcl_EvalObjEx<\/b>:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"23%\">\n<p style=\"margin-top: 1em\"><b>TCL_EVAL_DIRECT<\/b><\/p>\n<\/td>\n<td width=\"12%\"><\/td>\n<td width=\"54%\">\n<p style=\"margin-top: 1em\">This flag is only used by <b>Tcl_EvalObjEx<\/b>; it is ignored by other procedures. If this flag bit is set, the script is not compiled to bytecodes; instead it is executed directly as is done by <b>Tcl_EvalEx<\/b>. The <b>TCL_EVAL_DIRECT<\/b> flag is useful in situations where the contents of a value are going to change immediately, so the bytecodes will not be reused in a future execution. In this case, it is faster to execute the script directly.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"23%\">\n<p><b>TCL_EVAL_GLOBAL<\/b><\/p>\n<\/td>\n<td width=\"12%\"><\/td>\n<td width=\"54%\">\n<p>If this flag is set, the script is evaluated in the global namespace instead of the current namespace and its variable context consists of global variables only (it ignores any Tcl procedures that are active).<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>MISCELLANEOUS DETAILS <a name=\"MISCELLANEOUS DETAILS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">During the processing of a Tcl command it is legal to make nested calls to evaluate other commands (this is how procedures and some control structures are implemented). If a code other than <b>TCL_OK<\/b> is returned from a nested <b>Tcl_EvalObjEx<\/b> invocation, then the caller should normally return immediately, passing that same return code back to its caller, and so on until the top-level application is reached. A few commands, like <b>for<\/b>, will check for certain return codes, like <b>TCL_BREAK<\/b> and <b>TCL_CONTINUE<\/b>, and process them specially without returning.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_EvalObjEx<\/b> keeps track of how many nested <b>Tcl_EvalObjEx<\/b> invocations are in progress for <i>interp<\/i>. If a code of <b>TCL_RETURN<\/b>, <b>TCL_BREAK<\/b>, or <b>TCL_CONTINUE<\/b> is about to be returned from the topmost <b>Tcl_EvalObjEx<\/b> invocation for <i>interp<\/i>, it converts the return code to <b>TCL_ERROR<\/b> and sets <i>interp<\/i>\u2019s result to an error message indicating that the <b>return<\/b>, <b>break<\/b>, or <b>continue<\/b> command was invoked in an inappropriate place. This means that top-level applications should never see a return code from <b>Tcl_EvalObjEx<\/b> other than <b>TCL_OK<\/b> or <b>TCL_ERROR<\/b>.<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">execute, file, global, result, script, value<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  Tcl_EvalObjEx, Tcl_EvalFile, Tcl_EvalObjv, Tcl_Eval, Tcl_EvalEx, Tcl_GlobalEval, Tcl_GlobalEvalObj, Tcl_VarEval, Tcl_VarEvalVA \u2212 execute Tcl scripts <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,3007,3684],"class_list":["post-7370","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-man3","tag-tcl_evalobjex"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7370","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=7370"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7370\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}