[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

add a command in ns



Hello, all,

In ns, when I add a new command(which I can use in Tcl script) for a class, 
like Node, I add something in Node::command, like:

                else  if (strcmp(argv[1], "setmode") == 0) {

                        mode = atoi( argv[2] );
                        return (TCL_OK);

                }

well, mode is a global variable I added.
It can invoke that piece of code,( I use gdb to see that).
but after that, it complains invalid command name:

I copy the err msg in gdb as follows, ( when run it outside the debugger, it 
reports the same error.)
-------------------------------
0x2a423c in Tcl_Main ()
(gdb) n
Single stepping until exit from function Tcl_Main, 
which has no line number information.
invalid command name ""
    while executing
"[$node_(0)  setmode  1]"

-----------------------------
so I must miss something, I am wondering what else I need to modify to 
add a new command that I can use in Tcl script.

Thanks a lot in advance!
yan