01: /*
02: * AppendCmd.java --
03: *
04: * Implements the built-in "append" Tcl command.
05: *
06: * Copyright (c) 1997 Cornell University.
07: * Copyright (c) 1997 Sun Microsystems, Inc.
08: *
09: * See the file "license.terms" for information on usage and
10: * redistribution of this file, and for a DISCLAIMER OF ALL
11: * WARRANTIES.
12: *
13: * RCS: @(#) $Id: AppendCmd.java,v 1.2 1999/07/28 01:59:49 mo Exp $
14: *
15: */
16:
17: package tcl.lang;
18:
19: /*
20: * This class implements the built-in "append" command in Tcl.
21: */
22:
23: class AppendCmd implements Command {
24:
25: /*
26: *----------------------------------------------------------------------
27: *
28: * cmdProc --
29: *
30: * This procedure is invoked as part of the Command interface to
31: * process the "append" Tcl command. See the user documentation
32: * for details on what it does.
33: *
34: * Results:
35: * None.
36: *
37: * Side effects:
38: * See the user documentation.
39: *
40: *----------------------------------------------------------------------
41: */
42:
43: public void cmdProc(Interp interp, // Current interpreter.
44: TclObject[] objv) // Argument list.
45: throws TclException // A standard Tcl exception.
46: {
47: TclObject varValue = null;
48:
49: if (objv.length < 2) {
50: throw new TclNumArgsException(interp, 1, objv,
51: "varName ?value value ...?");
52: } else if (objv.length == 2) {
53: interp.setResult(interp.getVar(objv[1], 0));
54: } else {
55: for (int i = 2; i < objv.length; i++) {
56: varValue = interp.setVar(objv[1], objv[i],
57: TCL.APPEND_VALUE);
58: }
59:
60: if (varValue != null) {
61: interp.setResult(varValue);
62: } else {
63: interp.resetResult();
64: }
65: }
66: }
67:
68: } // end AppendCmd
|