[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns]Tcl variable name from C++
> There is a way to lookup an object if you know the name that Tcl gives it
> using TclObject::lookup(_o121). But is there a way of getting the actual
> variable name from this ?
>
> As an example if I have
>
> set node1 [$ns node]
>
> then $node1 is of the form _o121 or similar. Can I get, from C++, the fact
> that it is called 'node1'.
Try this:
set node1 [$ns node]
$node1 set tclname node1
then from C++
pNode = (Node*)TclObject::lookup(..);
Tcl::instance().evalf("%s set tclname");
pName = Tcl::instance().result();
pName should point to a string with "node1" in it.
(I do admit to having typed this into this mail message and not actually
tried it, so I may have a typo or something, but the idea is correct)
George