1<HTML><HEAD><TITLE>Built-In Commands - eval manual page</TITLE></HEAD><BODY> 2<H3><A NAME="M2">NAME</A></H3> 3eval - Evaluate a Tcl script 4<H3><A NAME="M3">SYNOPSIS</A></H3> 5<B>eval </B><I>arg </I>?<I>arg ...</I>?<BR> 6<H3><A NAME="M4">DESCRIPTION</A></H3> 7<B>Eval</B> takes one or more arguments, which together comprise a Tcl 8script containing one or more commands. 9<B>Eval</B> concatenates all its arguments in the same 10fashion as the <B><A HREF="../TclCmd/concat.htm">concat</A></B> command, passes the concatenated string to the 11Tcl interpreter recursively, and returns the result of that 12evaluation (or any error generated by it). 13Note that the <B><A HREF="../TclCmd/list.htm">list</A></B> command quotes sequences of words in such a 14way that they are not further expanded by the <B>eval</B> command. 15<H3><A NAME="M5">EXAMPLE</A></H3> 16This procedure acts in a way that is analogous to the <B><A HREF="../TclCmd/lappend.htm">lappend</A></B> 17command, except it inserts the argument values at the start of the 18list in the variable: 19<PRE>proc lprepend {varName args} { 20 upvar 1 $varName var 21 # Ensure that the variable exists and contains a list 22 lappend var 23 # Now we insert all the arguments in one go 24 set var [<B>eval</B> [list linsert $var 0] $args] 25}</PRE> 26<H3><A NAME="M6">KEYWORDS</A></H3> 27<A href="../Keywords/C.htm#concatenate">concatenate</A>, <A href="../Keywords/E.htm#evaluate">evaluate</A>, <A href="../Keywords/S.htm#script">script</A> 28<H3><A NAME="M7">SEE ALSO</A></H3> 29<B><A HREF="../TclCmd/catch.htm">catch</A></B>, <B><A HREF="../TclCmd/concat.htm">concat</A></B>, <B><A HREF="../TclCmd/error.htm">error</A></B>, <B><A HREF="../TclCmd/list.htm">list</A></B>, <B><A HREF="../TclCmd/subst.htm">subst</A></B>, <B><A HREF="../TclCmd/tclvars.htm">tclvars</A></B> 30<HR><PRE> 31<A HREF="../copyright.htm">Copyright</A> © 1993 The Regents of the University of California. 32<A HREF="../copyright.htm">Copyright</A> © 1994-1996 Sun Microsystems, Inc. 33<A HREF="../copyright.htm">Copyright</A> © 1995-1997 Roger E. Critchlow Jr.</PRE> 34</BODY></HTML> 35