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

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



To call a C++ function within tcl you need to define the method "command"
in your class. Then call your function from the method "command" ..... eg

int PacketQueue::command(int argc, const char*const* argv){

	if(argc==2){
		if (strcmp(argv[1], "myfn") == 0) {
			myfn();
		}
		return (TCL_OK);
	}
}

then from tcl you would say 

set a [new PacketQueue]
$a myfn

cheers
debo

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?
> Thanks a lot... :)
> 
>      Jay...
> 
>