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

Re: [ns] use c++ fuction in ns script?




> On Mon, 26 Feb 2001, Chen Wen-Jen wrote:
> 
>  hi...
>  I add some variables and fuctions to queue.h and queue.cc.
>  
>  In queue.cc, I do this :
>               bind("myvar_",&myvar_);
>  So, I can get myvar in ns script now.
>  
>  My question is :
>  Could I call my functions in ns script?
>  for ex,
>  $myqueue myfuction
>  
>  If yes, how?
>  What files Should I modify?
 
Modify the .cc file in which you do the implementation of "myqueue".
 
 Add the following 
  
  int Myqueue:command(int argc, const char*const* argv)
  {
    if(argc==2)
 	{
             if (strcmp(argv[1], "myfunction") == 0) {
                 // Implement here,  what you want to do on 
                 // invocation of $myqueue myfuction 
                 return TCL_OK;
             }  
   }
 
 For more information refer section 3.4.4. of ns manual.
 
 
 -amit