hi all

i am a nascent user of ns2. itried one example from tutorial "NS by example" 
the code is written below
// Jae Chung 7-13-99
// Example of a aimple and dull Agent that
// illustrates the use of OTcl linkages
//code is ex-linkage.cc

#include <stdio.h>
#include <string.h>
#include "agent.h"


class MyAgent : public Agent {
public:
        MyAgent();
protected:
        int command(int argc, const char*const* argv);
private:
        int    my_var1;
        double my_var2;
        void   MyPrivFunc(void);
};


static class MyAgentClass : public TclClass {
public:
        MyAgentClass() : TclClass("Agent/MyAgentOtcl") {}
        TclObject* create(int, const char*const*) {
                return(new MyAgent());
        }
} class_my_agent;


MyAgent::MyAgent() : Agent(PT_UDP) {
       bind("my_var1_otcl", &my_var1);
       bind("my_var2_otcl", &my_var2);
}


int MyAgent::command(int argc, const char*const* argv) {
      if(argc == 2) {
           if(strcmp(argv[1], "call-my-priv-func") == 0) {
                  MyPrivFunc();
                  return(TCL_OK);
           }
      }
      return(Agent::command(argc, argv));
}


void MyAgent::MyPrivFunc(void) {
      Tcl& tcl = Tcl::instance();
      tcl.eval("puts \"Message From MyPrivFunc\"");
      tcl.evalf("puts \"     my_var1 = %d\"", my_var1);
      tcl.evalf("puts \"     my_var2 = %f\"", my_var2);
}

the tutorial says to put the ex-linkage.o in the make file and then run the 
make command. on the first hand the make command is running.
then i do the following steps
./configure, make clean, make

after that i run the tcl script which is given below
# Jae Chung  7-13-99

# Create MyAgent (This will give two warning messages that 
# no default vaules exist for my_var1_otcl and my_var2_otcl)
set myagent [new Agent/MyAgentOtcl]

# Set configurable parameters of MyAgent
$myagent set my_var1_otcl 2
$myagent set my_var2_otcl 3.14

# Give a command to MyAgent
$myagent call-my-priv-func

but the i receive the  following error
invalid command name "Agent/MyAgentOtcl"
    while executing
"Agent/MyAgentOtcl create _o3 "
    invoked from within
"catch "$className create $o $args" msg"
    invoked from within
"if [catch "$className create $o $args" msg] {
if [string match "__FAILED_SHADOW_OBJECT_" $msg] {
delete $o
return ""
}
global errorInfo
error "class $..."
    (procedure "new" line 3)
    invoked from within
"new Agent/MyAgentOtcl"
    invoked from within
"set myagent [new Agent/MyAgentOtcl]"
    (file "ex-linkage.tcl" line 5)
also on opening the make file i find that ex-linkage.o is missing from the 
makefile. 
since i have a project i my hand kindly help me

thanx in advance

Neeraj
Hindu college of engineering, sonepat

Neeraj

Reply via email to