[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: otcl syntax question
On Tue, 9 Jun 1998, Ramon Caceres wrote:
> I would like to access the node id (e.g., "1") from otcl
> code associated with an agent that is attached to the node.
> In particular:
>
> set n [$ns node]
> set l [new Agent/LossMonitor]
> $ns attach-agent $n $l
>
> results in
>
> Node _o9(id 1)
> ...
> Agents at node (possibly in order of creation):
> _o32 Agent/LossMonitor portID: 0(256)
>
> In tcl/lib/ns-agent.tcl, if I do
>
> Agent/LossMonitor instproc log-loss {} {
> puts "log-loss: $self"
> }
>
> then $self evaluates to "_o32". How do I print the node id "1"
> instead of the agent id "_o32" from that same piece of code?
Ramon,
You could try
puts "log-loss: [[$self set node_] id]"
1. [$whateverAgent set node_] gives the pointer to the attached node.
2. [$whateverNode id] gives the node id
-Polly
>
> Thanks very much.
>
> --Ramon
>