diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2004-11-09 10:25:22 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2004-11-09 10:25:22 (GMT) |
commit | 89675228f03f60dc605bc085eaa2ac337dcfef01 (patch) | |
tree | 36809bc3808f6b5627b846cdbdd79946a91ac0ad | |
parent | 428d469fccf81096d51d799729c437daba398c94 (diff) | |
download | tcl-89675228f03f60dc605bc085eaa2ac337dcfef01.zip tcl-89675228f03f60dc605bc085eaa2ac337dcfef01.tar.gz tcl-89675228f03f60dc605bc085eaa2ac337dcfef01.tar.bz2 |
Clarify return code documentation. [Bug 1062647]
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | doc/catch.n | 27 |
2 files changed, 24 insertions, 7 deletions
@@ -1,3 +1,7 @@ +2004-11-09 Donal K. Fellows <donal.k.fellows@man.ac.uk> + + * doc/catch.n: Clarify documentation on return codes. [Bug 1062647] + 2004-11-02 Don Porter <dgp@users.sourceforge.net> * changes: Updates for Tcl 8.4.8 release. diff --git a/doc/catch.n b/doc/catch.n index 5bae0c6..01770aa 100644 --- a/doc/catch.n +++ b/doc/catch.n @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: catch.n,v 1.5.18.1 2004/10/27 09:35:38 dkf Exp $ +'\" RCS: @(#) $Id: catch.n,v 1.5.18.2 2004/11/09 10:25:23 dkf Exp $ '\" .so man.macros .TH catch n "8.0" Tcl "Tcl Built-In Commands" @@ -20,15 +20,28 @@ catch \- Evaluate script and trap exceptional returns .SH DESCRIPTION .PP The \fBcatch\fR command may be used to prevent errors from aborting command -interpretation. \fBCatch\fR calls the Tcl interpreter recursively to +interpretation. The \fBcatch\fR command calls the Tcl interpreter recursively to execute \fIscript\fR, and always returns without raising an error, regardless of any errors that might occur while executing \fIscript\fR. .PP If \fIscript\fR raises an error, \fBcatch\fR will return a non-zero integer -value corresponding to one of the exceptional return codes (see tcl.h -for the definitions of code values). If the \fIvarName\fR argument is -given, then the variable it names is set to the error message from -interpreting \fIscript\fR. +value corresponding to the exceptional return code returned by evaluation +of \fIscript\fR. Tcl defines the normal return code from script +evaluation to be zero (0), or \fBTCL_OK\fR. Tcl also defines four exceptional +return codes: 1 (\fBTCL_ERROR\fR), 2 (\fBTCL_RETURN\fR), 3 (\fBTCL_BREAK\fR), +and 4 (\fBTCL_CONTINUE\fR). Errors during evaluation of a script are indicated +by a return code of \fBTCL_ERROR\fR. The other exceptional return codes are +returned by the \fBreturn\fR, \fBbreak\fR, and \fBcontinue\fR commands +and in other special situations as documented. Tcl packages can define +new commands that return other integer values as return codes as well, +and scripts that make use of the \fBreturn -code\fR command can also +have return codes other than the five defined by Tcl. +.PP +If the \fIvarName\fR argument is given, then the variable it names is +set to the result of the script evaluation. When the return code from +the script is 1 (\fBTCL_ERROR\fR), the value stored in \fIvarName\fR is an error +message. When the return code from the script is 0 (\fBTCL_OK\fR), the value +stored in \fIresultVarName\fR is the value returned from \fIscript\fR. .PP If \fIscript\fR does not raise an error, \fBcatch\fR will return 0 (\fBTCL_OK\fR) and set the variable to the value returned from \fIscript\fR. @@ -61,7 +74,7 @@ proc foo {} { .CE .SH "SEE ALSO" -error(n), break(n), continue(n) +break(n), continue(n), error(n), return(n), tclvars(n) .SH KEYWORDS catch, error |