Hi, the command function of classes is used if you want to use member
functions of your C++ class from your tcl code. For example your
member function name is deneme and your class name is DenemeAgent, you
can call this function from your tcl code via command function.
"deneme" function hasn't any parameter, and returns an integer value.
In this case, appropriate code is below

int DenemeAgent::command(int argc, const char*const*argv) {
    Tcl& tcl = Tcl::instance();
    if (argc == 2) {
        if (strcmp(argv[1], "deneme") == 0) {
            int sender = deneme();
            tcl.tesultf("%d", sender);
            return TCL_OK;
        }
    }
return (SRMAgent::command(argc, argv));
}


Tcl Code is below:

set myAgent [new Agent/DenemeAgent]
$myAgent deneme ---> via this code, you can call your member function
deneme from your tcl code. But you need a command function in your c++
code as previous code.


Have a good day.

Guzin ULUTAS (CEng)


Reply via email to