<HTML><HEAD><TITLE>Built-In Commands - catch manual page</TITLE></HEAD><BODY> <H3><A NAME="M2">NAME</A></H3> catch - Evaluate script and trap exceptional returns <H3><A NAME="M3">SYNOPSIS</A></H3> <B>catch</B><I> script </I>?<I>varName</I>?<BR> <H3><A NAME="M4">DESCRIPTION</A></H3> The <B>catch</B> command may be used to prevent errors from aborting command interpretation. <B>Catch</B> calls the Tcl interpreter recursively to execute <I>script</I>, and always returns a TCL_OK code, regardless of any errors that might occur while executing <I>script</I>. The return value from <B>catch</B> is a decimal string giving the code returned by the Tcl interpreter after executing <I>script</I>. This will be <B>0</B> (TCL_OK) if there were no errors in <I>script</I>; otherwise it will have a non-zero value corresponding to one of the exceptional return codes (see tcl.h for the definitions of code values). If the <I>varName</I> argument is given, then it gives the name of a variable; <B>catch</B> will set the variable to the string returned from <I>script</I> (either a result or an error message). <P> Note that <B>catch</B> catches all exceptions, including those generated by <B><A HREF="../TclCmd/break.htm">break</A></B> and <B><A HREF="../TclCmd/continue.htm">continue</A></B> as well as errors. <H3><A NAME="M5">KEYWORDS</A></H3> <A href="../Keywords/C.htm#catch">catch</A>, <A href="../Keywords/E.htm#error">error</A> <HR><PRE> <A HREF="../copyright.htm">Copyright</A> © 1993-1994 The Regents of the University of California. <A HREF="../copyright.htm">Copyright</A> © 1994-1996 Sun Microsystems, Inc. <A HREF="../copyright.htm">Copyright</A> © 1995-1997 Roger E. Critchlow Jr.</PRE> </BODY></HTML>