wasCSharpSQLite – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * ExprCmd.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: ExprCmd.java,v 1.2 1999/05/08 23:59:30 dejong Exp $
14 *
15 */
16 using System.Text;
17 namespace tcl.lang
18 {
19  
20 /// <summary> This class implements the built-in "expr" command in Tcl.</summary>
21  
22 class ExprCmd : Command
23 {
24 /// <summary> Evaluates a Tcl expression. See Tcl user documentation for
25 /// details.
26 /// </summary>
27 /// <exception cref=""> TclException If malformed expression.
28 /// </exception>
29  
30 public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
31 {
32 if ( argv.Length < 2 )
33 {
34 throw new TclNumArgsException( interp, 1, argv, "arg ?arg ...?" );
35 }
36  
37 if ( argv.Length == 2 )
38 {
39  
40 interp.setResult( interp.expr.eval( interp, argv[1].ToString() ) );
41 }
42 else
43 {
44 StringBuilder sbuf = new StringBuilder();
45  
46 sbuf.Append( argv[1].ToString() );
47 for ( int i = 2; i < argv.Length; i++ )
48 {
49 sbuf.Append( ' ' );
50  
51 sbuf.Append( argv[i].ToString() );
52 }
53 interp.setResult( interp.expr.eval( interp, sbuf.ToString() ) );
54 }
55 return TCL.CompletionCode.RETURN;
56 }
57 }
58 }