[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] Tcl problem
Hi, everybody:
When I define a Tcl procedure, I got some trouble to bring the
variable which is defined outside the proc into the proc.
e.g.
:
:
set n(1) [$ns node]
set agent1 [Agent/...]
:
proc myproc {} {
global ns n(1) agent1
$ns attach-agent $n(1) $agent1
:
:
}
When I call this proc, I got an error:
ns: myproc: can't read "n(1)": no such variable
If I remove the brackets on all n(1), and define the node name as n1,
it is OK and the proc works well. Since I need to randomly select
some nodes in the proc, I have to make the node name changable, such
like: n($i). Can any one tell me what's wrong and how to do it?
Thanks.
Jianxue Huang