summaryrefslogtreecommitdiffstats
path: root/doc/catch.n
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-10-27 09:35:37 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-10-27 09:35:37 (GMT)
commit7ea5d4dbe8b82a86701cec95132a8a9557a5f105 (patch)
tree2f3f979845a50074bb8e2a0687cd98cb14ae6c26 /doc/catch.n
parenta50314f88b2a6af554553927c9c0e590c0acf7dc (diff)
downloadtcl-7ea5d4dbe8b82a86701cec95132a8a9557a5f105.zip
tcl-7ea5d4dbe8b82a86701cec95132a8a9557a5f105.tar.gz
tcl-7ea5d4dbe8b82a86701cec95132a8a9557a5f105.tar.bz2
Backport many doc fixes
Diffstat (limited to 'doc/catch.n')
-rw-r--r--doc/catch.n12
1 files changed, 5 insertions, 7 deletions
diff --git a/doc/catch.n b/doc/catch.n
index 01d0628..5bae0c6 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 2000/09/07 14:27:46 poenitz Exp $
+'\" RCS: @(#) $Id: catch.n,v 1.5.18.1 2004/10/27 09:35:38 dkf Exp $
'\"
.so man.macros
.TH catch n "8.0" Tcl "Tcl Built-In Commands"
@@ -31,7 +31,7 @@ given, then the variable it names is set to the error message from
interpreting \fIscript\fR.
.PP
If \fIscript\fR does not raise an error, \fBcatch\fR will return 0
-(TCL_OK) and set the variable to the value returned from \fIscript\fR.
+(\fBTCL_OK\fR) and set the variable to the value returned from \fIscript\fR.
.PP
Note that \fBcatch\fR catches all exceptions, including those
generated by \fBbreak\fR and \fBcontinue\fR as well as errors. The
@@ -42,23 +42,21 @@ script is compiled as well and any syntax errors will generate a Tcl
error.
.SH EXAMPLES
-
The \fBcatch\fR command may be used in an \fBif\fR to branch based on
the success of a script.
-
.CS
-if { [catch {open $someFile w} fid] } {
+if { [\fBcatch\fR {open $someFile w} fid] } {
puts stderr "Could not open $someFile for writing\\n$fid"
exit 1
}
.CE
+.PP
The \fBcatch\fR command will not catch compiled syntax errors. The
first time proc \fBfoo\fR is called, the body will be compiled and a
Tcl error will be generated.
-
.CS
proc foo {} {
- catch {expr {1 +- }}
+ \fBcatch\fR {expr {1 +- }}
}
.CE