abstract void cmdProc(Interp interp, TclObject argv[])
cmdProc is invoked to process a Tcl command for interp. The argv array contains the arguments passed to the command: argv[0] is the name of the command and the rest of the array contains the rest of the arguments.
If the command execution completes normally, this method should pass the result object back to the interpreter by calling interp.setResult and then return normally. If an error occurs during the command execution, cmdProc should throw a TclException with appropriate completion code and error messages (see the manual entry of TclException for details.)
If your command requires clean-up when it's removed from the interpreter, use the CommandWithDispose interface instead of the Command interface. See the CommandWithDispose manual entry for details.
import tcl.lang; class AddCmd implements Command { public cmdProc(Interp interp, TclObject argv[]) throws TclException { if (argv.length != 3) { throw new TclNumArgsException(interp, 1, argv, "num1 num2"); } int num1 = TclInteger.get(interp, argv[1]); int num2 = TclInteger.get(interp, argv[2]); TclObject result = TclInteger.newInstance(num1 + num2); interp.setResult(result); } }
Copyright © 1998 Sun Microsystems, Inc. Copyright © 1995-1997 Roger E. Critchlow Jr.