01: /*
02: * TellCmd.java --
03: *
04: * Copyright (c) 1997 Sun Microsystems, Inc.
05: *
06: * See the file "license.terms" for information on usage and
07: * redistribution of this file, and for a DISCLAIMER OF ALL
08: * WARRANTIES.
09: *
10: * RCS: @(#) $Id: TellCmd.java,v 1.2 2005/10/07 06:50:09 mdejong Exp $
11: *
12: */
13:
14: package tcl.lang;
15:
16: import java.util.*;
17: import java.io.*;
18:
19: /**
20: * This class implements the built-in "tell" command in Tcl.
21: */
22:
23: class TellCmd implements Command {
24:
25: /**
26: * This procedure is invoked to process the "tell" Tcl command.
27: * See the user documentation for details on what it does.
28: *
29: * @param interp the current interpreter.
30: * @param argv command arguments.
31: */
32:
33: public void cmdProc(Interp interp, TclObject argv[])
34: throws TclException {
35:
36: Channel chan; /* The channel being operated on this method */
37:
38: if (argv.length != 2) {
39: throw new TclNumArgsException(interp, 1, argv, "channelId");
40: }
41:
42: chan = TclIO.getChannel(interp, argv[1].toString());
43: if (chan == null) {
44: throw new TclException(interp,
45: "can not find channel named \""
46: + argv[1].toString() + "\"");
47: }
48:
49: try {
50: interp.setResult((int) chan.tell());
51: } catch (IOException e) {
52: throw new TclException(interp, "Error in TellCmd");
53: }
54: }
55: }
|