Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用这样的循环创建了变量:
for {set i 0} {$i<5} {incr i} { set n($i) [$ns node] }
如何通过某些程序调用 n($i) 变量?我称之为
global n(0) n(1) n(2) n(3) n(4)
但我得到了错误:
ns: record: bad variable name "n(0)": upvar 在执行时不会创建一个看起来像数组元素的标量变量
我想通了: global n 调用数组变量n就足够了。
global n