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

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



hi, 
  i remember i had to go through a similar problem once. and the procedure
for accesssing the C++ functions actually turned out pretty complex. there
was a need to add a bind() procedure in the .cc file. however, if this
simple way of binding the variable and adding the code to command() works
please do reply back as  i believe this information will be quite
valuable.

Shailesh Sheoran
M.ASc. 
Department of Electrical Engineering
University of British Columbia

On Mon, 26 Feb 2001, AMIT JAIN wrote:

> 
> 
> > 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
>  
>  
> 
> 
>