Seth Woolley's Man Viewer

Tcl_Eval(3) - Tcl_Eval, Tcl_EvalEx, Tcl_EvalFile, Tcl_EvalObjEx, Tcl_EvalObjv, Tcl_GlobalEval, Tcl_GlobalEvalObj, Tcl_VarEval, Tcl_VarEvalVA - execute Tcl scripts - man 3 Tcl_Eval

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

Tcl_Eval(3)                 Tcl Library Procedures                 Tcl_Eval(3)


       Tcl_EvalObjEx,   Tcl_EvalFile,   Tcl_EvalObjv,   Tcl_Eval,  Tcl_EvalEx,
       Tcl_GlobalEval, Tcl_GlobalEvalObj, Tcl_VarEval, Tcl_VarEvalVA - execute
       Tcl scripts

       #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, string(3,n), string(3,n), ... (char *) NULL)                  |

       int                                                                     |
       Tcl_VarEvalVA(interp, argList)                                          |

ARGUMENTS                                                                      |
       Tcl_Interp   *interp      (in(1,8))                                          ||
                                           Interpreter in(1,8) which to execute the |
                                           script.   The  interpreter's result |
                                           is modified to hold the  result  or |
                                           error(8,n) message from the script.      |

       Tcl_Obj      *objPtr      (in(1,8))                                          ||
                                           A Tcl object containing the  script |
                                           to execute.                         |

       int          flags        (in(1,8))                                          ||
                                           ORed combination of flag bits  that |
                                           specify     additional     options. |
                                           TCL_EVAL_GLOBAL and TCL_EVAL_DIRECT |
                                           are currently supported.            |

       CONST char   *file-                                                     |
       Name    (in(1,8))                                          |                 |
                                           Name of a  file(1,n)  containing  a  Tcl |
                                           script.                             |

       int          objc         (in(1,8))                                          ||
                                           The number of objects in(1,8) the  array |
                                           pointed  to by objPtr; this is also |
                                           the number of words in(1,8) the command. |

       Tcl_Obj      **objv       (in(1,8))                                          ||
                                           Points to an array of  pointers  to |
                                           objects;   each  object  holds  the |
                                           value of a single word in(1,8) the  com- |
                                           mand to execute.                    |

       int          num-                                                       |
       Bytes     (in(1,8))                                          |               |
                                           The number of bytes in(1,8) script,  not |
                                           including   any   null  terminating |
                                           character.  If -1, then all charac- |
                                           ters  up to the first null byte are |
                                           used.                               |

       CONST                                                                   |
       char   *script      (in(1,8))                                          |     |
                                           Points  to  first byte of script to |
                                           execute    (null-terminated     and |
                                           UTF-8).                             |

       char         *string(3,n)      (in(1,8))                                          ||
                                           String  forming  part  of   a   Tcl |
                                           script.                             |

       va_list      argList      (in(1,8))                                          ||
                                           An argument list  which  must  have |
                                           been        initialised       using |
                                           TCL_VARARGS_START,   and    cleared |
                                           using va_end.                       |
_________________________________________________________________              |

DESCRIPTION                                                                    |
       The  procedures  described  here  are invoked to execute Tcl scripts in(1,8) |
       various forms.  Tcl_EvalObjEx is the core procedure and is used by many |
       of the others.  It executes the commands in(1,8) the script stored in(1,8) objPtr |
       until either an error(8,n) occurs or the end of the script is  reached.   If |
       this  is the first time(1,2,n) objPtr has been executed, its commands are com- |
       piled into bytecode instructions which are then  executed.   The  byte- |
       codes  are  saved in(1,8) objPtr so that the compilation step can be skipped |
       if(3,n) the object is evaluated again in(1,8) 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(1,8) an extension.  In addition, a result |
       value or error(8,n) message is left in(1,8) interp's result; it can be  retrieved |
       using Tcl_GetObjResult.                                                 |

       Tcl_EvalFile  reads  the  file(1,n) given by fileName and evaluates its con- |
       tents as a Tcl script.  It returns the same information as  Tcl_EvalOb- |
       jEx.   If  the  file(1,n)  couldn't  be read(2,n,1 builtins) then a Tcl error(8,n) is returned to |
       describe why the file(1,n) couldn't be read.  The eofchar for files is '\32' |
       (^Z)  for  all  platforms.   If you require a ``^Z'' in(1,8) code for string(3,n) |
       comparison, you can use ``\032'' or ``\u001a'', which  will  be  safely |
       substituted by the Tcl interpreter into ``^Z''.

       Tcl_EvalObjv  executes a single pre-parsed command instead of a script.
       The objc and objv arguments contain the values of the words for the Tcl
       command,  one  word in(1,8) each object in(1,8) objv.  Tcl_EvalObjv evaluates the
       command and returns a completion code and result just like  Tcl_EvalOb-

       Tcl_Eval  is similar to Tcl_EvalObjEx except that the script to be exe-
       cuted is supplied as a string(3,n) instead of an object and  no  compilation
       occurs.   The  string(3,n)  should  be a proper UTF-8 string(3,n) as converted by
       Tcl_ExternalToUtfDString or Tcl_ExternalToUtf when it is known to  pos-
       sibly  contain upper ASCII characters who's possible combinations might
       be a UTF-8 special code.  The string(3,n) is parsed  and  executed  directly
       (using  Tcl_EvalObjv)  instead  of compiling it and executing the byte-
       codes.  In situations where it is known that the script will  never  be
       executed again, Tcl_Eval may be faster than Tcl_EvalObjEx.
        Tcl_Eval returns a completion code and result just like Tcl_EvalObjEx.
       Note: for backward compatibility with versions before Tcl 8.0, Tcl_Eval
       copies  the  object  result  in(1,8) interp to interp->result (use is depre-
       cated) where it can be accessed directly.
        This makes Tcl_Eval somewhat slower than Tcl_EvalEx, which doesn't  do
       the copy.

       Tcl_EvalEx  is  an  extended  version(1,3,5) of Tcl_Eval that takes additional
       arguments numBytes and flags.  For the efficiency reason  given  above,
       Tcl_EvalEx is generally preferred over Tcl_Eval.

       Tcl_GlobalEval  and Tcl_GlobalEvalObj are older procedures that are now
       deprecated.  They are similar to Tcl_EvalEx  and  Tcl_EvalObjEx  except
       that  the  script is evaluated in(1,8) the global namespace and its variable
       context consists of global variables only (it ignores  any  Tcl  proce-
       dures  that  are  active).  These functions are equivalent to using the
       TCL_EVAL_GLOBAL flag (see below).

       Tcl_VarEval takes any number of string(3,n) arguments of  any  length,  con-
       catenates  them  into  a  single string(3,n), then calls Tcl_Eval to execute
       that string(3,n) as a Tcl command.  It returns the result of the command and
       also  modifies  interp->result  in(1,8)  the same way as Tcl_Eval.  The last
       argument to Tcl_VarEval must be NULL to indicate the end of  arguments.
       Tcl_VarEval is now deprecated.

       Tcl_VarEvalVA  is the same as Tcl_VarEval except that instead of taking
       a variable  number  of  arguments  it  takes  an  argument  list.  Like
       Tcl_VarEval, Tcl_VarEvalVA is deprecated.

       Any  ORed combination of the following values may be used for the flags
       argument to procedures such as Tcl_EvalObjEx:

       TCL_EVAL_DIRECT        This flag is only used by Tcl_EvalObjEx;  it  is
                              ignored  by  other procedures.  If this flag bit
                              is set(7,n,1 builtins), the script is not compiled to bytecodes;
                              instead  it  is  executed directly as is done by
                              Tcl_EvalEx.  The TCL_EVAL_DIRECT flag is  useful
                              in(1,8)  situations  where  the contents of an object
                              are going to change immediately,  so  the  byte-
                              codes won't be reused in(1,8) a future execution.  In
                              this case, it's faster  to  execute  the  script

       TCL_EVAL_GLOBAL        If  this flag is set(7,n,1 builtins), the script is processed at
                              global level.  This means that it  is  evaluated
                              in(1,8) the global namespace and its variable context
                              consists of global variables  only  (it  ignores
                              any Tcl procedures at are active).

       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 TCL_OK is returned
       from a nested Tcl_EvalObjEx 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  for,  will  check  for  certain  return codes, like TCL_BREAK and
       TCL_CONTINUE, and process them specially without returning.

       Tcl_EvalObjEx keeps track of how many nested Tcl_EvalObjEx  invocations
       are  in(1,8)  progress  for  interp.  If a code of TCL_RETURN, TCL_BREAK, or
       TCL_CONTINUE is about to be returned  from  the  topmost  Tcl_EvalObjEx
       invocation  for  interp,  it  converts the return code to TCL_ERROR and
       sets interp's result to an error(8,n) message indicating  that  the  return,
       break, or continue command was invoked in(1,8) an inappropriate place.  This
       means that top-level applications should never see a return  code  from
       Tcl_EvalObjEx other then TCL_OK or TCL_ERROR.

       execute, file(1,n), global, object, result, script

Tcl                                   8.1                          Tcl_Eval(3)

References for this manual (incoming links)