Tcl_Eval(3) Tcl Library Procedures Tcl_Eval(3)
__________________________________________________________________________________________________________________________________________________
NAME
Tcl_EvalObjEx, Tcl_EvalFile, Tcl_EvalObjv, Tcl_Eval, Tcl_EvalEx, Tcl_GlobalEval, Tcl_GlobalEvalObj, Tcl_VarEval, Tcl_VarEvalVA - execute
Tcl scripts
SYNOPSIS
#include <tcl.h>
int
Tcl_EvalObjEx(interp, objPtr, flags)
int
Tcl_EvalFile(interp, fileName)
int
Tcl_EvalObjv(interp, objc, objv, flags)
int
Tcl_Eval(interp, script)
int
Tcl_EvalEx(interp, script, numBytes, flags)
int
Tcl_GlobalEval(interp, script)
int
Tcl_GlobalEvalObj(interp, objPtr)
int
Tcl_VarEval(interp, part, part, ... (char *) NULL)
int
Tcl_VarEvalVA(interp, argList)
ARGUMENTS
Tcl_Interp *interp (in) Interpreter in which to execute the script. The interpreter's result is modified to hold the result or
error message from the script.
Tcl_Obj *objPtr (in) A Tcl object containing the script to execute.
int flags (in) ORed combination of flag bits that specify additional options. TCL_EVAL_GLOBAL and TCL_EVAL_DIRECT are
currently supported.
const char *fileName (in) Name of a file containing a Tcl script.
int objc (in) The number of objects in the array pointed to by objPtr; this is also the number of words in the com-
mand.
Tcl_Obj **objv (in) Points to an array of pointers to objects; each object holds the value of a single word in the command
to execute.
int numBytes (in) The number of bytes in script, not including any null terminating character. If -1, then all characters
up to the first null byte are used.
const char *script (in) Points to first byte of script to execute (null-terminated and UTF-8).
char *part (in) String forming part of a Tcl script.
va_list argList (in) An argument list which must have been initialized using va_start, and cleared using va_end.
_________________________________________________________________
DESCRIPTION
The procedures described here are invoked to execute Tcl scripts in various forms. Tcl_EvalObjEx is the core procedure and is used by many
of the others. It executes the commands in the script stored in objPtr until either an error occurs or the end of the script is reached.
If this is the first time objPtr has been executed, its commands are compiled into bytecode instructions which are then executed. The
bytecodes are saved in objPtr so that the compilation step can be skipped if the object is evaluated again in the future.
The return value from Tcl_EvalObjEx (and all the other procedures described here) is a Tcl completion code with one of the values TCL_OK,
TCL_ERROR, TCL_RETURN, TCL_BREAK, or TCL_CONTINUE, or possibly some other integer value originating in an extension. In addition, a result
value or error message is left in interp's result; it can be retrieved using Tcl_GetObjResult.
Tcl_EvalFile reads the file given by fileName and evaluates its contents as a Tcl script. It returns the same information as Tcl_EvalOb-
jEx. 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
"32" (^Z) for all platforms. If you require a "^Z" in code for string comparison, you can use "