/*
* ExprCmd.java
*
* Copyright (c) 1997 Cornell University.
* Copyright (c) 1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and
* redistribution of this file, and for a DISCLAIMER OF ALL
* WARRANTIES.
*
* Included in SQLite3 port to C# for use in testharness only; 2008 Noah B Hart
*
* RCS @(#) $Id: ExprCmd.java,v 1.2 1999/05/08 23:59:30 dejong Exp $
*
*/
using System.Text;
namespace tcl.lang
{
/// This class implements the built-in "expr" command in Tcl.
class ExprCmd : Command
{
/// Evaluates a Tcl expression. See Tcl user documentation for
/// details.
///
/// TclException If malformed expression.
///
public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
{
if ( argv.Length < 2 )
{
throw new TclNumArgsException( interp, 1, argv, "arg ?arg ...?" );
}
if ( argv.Length == 2 )
{
interp.setResult( interp.expr.eval( interp, argv[1].ToString() ) );
}
else
{
StringBuilder sbuf = new StringBuilder();
sbuf.Append( argv[1].ToString() );
for ( int i = 2; i < argv.Length; i++ )
{
sbuf.Append( ' ' );
sbuf.Append( argv[i].ToString() );
}
interp.setResult( interp.expr.eval( interp, sbuf.ToString() ) );
}
return TCL.CompletionCode.RETURN;
}
}
}