wasCSharpSQLite – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* |
2 | * IncrCmd.java |
||
3 | * |
||
4 | * Copyright (c) 1997 Cornell University. |
||
5 | * Copyright (c) 1997-1998 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: IncrCmd.java,v 1.2 1999/08/03 02:56:23 mo Exp $ |
||
14 | * |
||
15 | */ |
||
16 | using System; |
||
17 | namespace tcl.lang |
||
18 | { |
||
19 | |||
20 | /// <summary> This class implements the built-in "incr" command in Tcl.</summary> |
||
21 | class IncrCmd : Command |
||
22 | { |
||
23 | /// <summary> This procedure is invoked to process the "incr" Tcl command. |
||
24 | /// See the user documentation for details on what it does. |
||
25 | /// </summary> |
||
26 | /// <exception cref=""> TclException if wrong # of args or increment is not an |
||
27 | /// integer. |
||
28 | /// </exception> |
||
29 | |||
30 | public TCL.CompletionCode cmdProc( Interp interp, TclObject[] objv ) |
||
31 | { |
||
32 | int incrAmount; |
||
33 | TclObject newValue; |
||
34 | |||
35 | if ( ( objv.Length != 2 ) && ( objv.Length != 3 ) ) |
||
36 | { |
||
37 | throw new TclNumArgsException( interp, 1, objv, "varName ?increment?" ); |
||
38 | } |
||
39 | |||
40 | // Calculate the amount to increment by. |
||
41 | |||
42 | if ( objv.Length == 2 ) |
||
43 | { |
||
44 | incrAmount = 1; |
||
45 | } |
||
46 | else |
||
47 | { |
||
48 | try |
||
49 | { |
||
50 | incrAmount = TclInteger.get( interp, objv[2] ); |
||
51 | } |
||
52 | catch ( TclException e ) |
||
53 | { |
||
54 | interp.addErrorInfo( "\n (reading increment)" ); |
||
55 | throw; |
||
56 | } |
||
57 | } |
||
58 | |||
59 | // Increment the variable's value. |
||
60 | |||
61 | newValue = Var.incrVar( interp, objv[1], null, incrAmount, TCL.VarFlag.LEAVE_ERR_MSG ); |
||
62 | |||
63 | // FIXME: we need to look at this exception throwing problem again |
||
64 | /* |
||
65 | if (newValue == null) { |
||
66 | return TCL_ERROR; |
||
67 | } |
||
68 | */ |
||
69 | |||
70 | // Set the interpreter's object result to refer to the variable's new |
||
71 | // value object. |
||
72 | |||
73 | interp.setResult( newValue ); |
||
74 | return TCL.CompletionCode.RETURN; |
||
75 | } |
||
76 | } |
||
77 | } |