Hi all,
  When I run the sample program about C++/Otcl linkage I got the error as 
described below:
  Program:
  class MyAgent : public Agent
{
 public:
  MyAgent();
 protected:
  int command(int *argc,const char *const* argv);
 private:
  int My_var1;
  double My_var2;
  void MyPrivFun(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)
  {
   MyPrivFun();
   return(TCL_OK);
  }
 }
 return(Agent : command(argc,argv));
}
  
void MyAgent :: MyPrivFun(void)
{
 Tcl& tcl=Tcl::instance();
 Tcl.eval("puts \"Message from MyPrivFun\"");
 Tcl.evalf("puts \"  my_var1= %d\"", my_var1);
 Tcl.evalf("puts \"  my_var2= %f\"", my_var2);
}
  ex-linkage.cc
   
   
  set myagent [new Agent/MyAgentOtcl]
  $myagent set my_var1_otcl 2
$myagent set my_var2_otcl 3.14
  $myagent call_my_priv_func
   
  ex-linkage.tcl
   
   
  Running above tcl script in ns-2.26 I got the error
  Invalid command name “Agent/MyAgentOtcl”
  While executing
  “A Agent/MyAgentOtcl create _o3”
  “catch “$className create $o $args” msg”
  (procedure “new” line 3)
  invoked from within
  “new Agent/MyAgentOtcl”
  invoked from within
  “set myagent [new Agent/MyAgentOtcl]”
              (file “ex-linkage.tcl” line 1)
   
   
  I apply the following procedure:
  Open "Makefile", add "ex-linkage.o" at the end of object file list. 
   Re-compile NS using the "make" command.
   Run tcl script.
   
  if anyone knows the solutins then immediately mail me...........
   
  Mahesh

                                
---------------------------------
 Why was V. Sehwag warned by the BCCI? Share your knowledge on Yahoo! Answers 
India
 Send instant messages to your online friends - NOW

Reply via email to