wasCSharpSQLite – Blame information for rev 4

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * CatchCmd.java
3 *
4 * Copyright (c) 1997 Cornell University.
5 * Copyright (c) 1997 Sun Microsystems, Inc.
6 *
7 * See the file "license.terms" for information on usage and
8 * redistribution of this file, and for a DISCLAIMER OF ALL
9 * WARRANTIES.
10 *
11 * Included in SQLite3 port to C# for use in testharness only; 2008 Noah B Hart
12 *
13 * RCS @(#) $Id: CatchCmd.java,v 1.2 2000/08/20 06:08:42 mo Exp $
14 *
15 */
16 using System;
17 namespace tcl.lang
18 {
19  
20 /// <summary> This class implements the built-in "catch" command in Tcl.</summary>
21  
22 class CatchCmd : Command
23 {
24 /// <summary> This procedure is invoked to process the "catch" Tcl command.
25 /// See the user documentation for details on what it does.
26 ///
27 /// </summary>
28 /// <param name="interp">the current interpreter.
29 /// </param>
30 /// <param name="argv">command arguments.
31 /// </param>
32 /// <exception cref=""> TclException if wrong number of arguments.
33 /// </exception>
34  
35 public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
36 {
37 if ( argv.Length != 2 && argv.Length != 3 )
38 {
39 throw new TclNumArgsException( interp, 1, argv, "command ?varName?" );
40 }
41  
42 TclObject result;
43 TCL.CompletionCode code = TCL.CompletionCode.OK;
44  
45 try
46 {
47 interp.eval( argv[1], 0 );
48 }
49 catch ( TclException e )
50 {
51 code = e.getCompletionCode();
52 }
53  
54 result = interp.getResult();
55  
56 if ( argv.Length == 3 )
57 {
58 try
59 {
60 interp.setVar( argv[2], result, 0 );
61 }
62 catch ( TclException e )
63 {
64 throw new TclException( interp, "couldn't save command result in variable" );
65 }
66 }
67  
68 interp.resetResult();
69 interp.setResult( TclInteger.newInstance( (int)code ) );
70 return TCL.CompletionCode.RETURN;
71 }
72 }
73 }