这是一段出错的代码:
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns node]
$node_($i) random-motion 0 ;
}
$node_(0) set X_ 5.0
$node_(0) set Y_ 2.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 390.0
$node_(1) set Y_ 386.0
$node_(1) set Z_ 0.0
报错:
$ ns example2.tcl
num_nodes is set 2
(_o15 cmd line 1)
invoked from within
"_o15 cmd random-motion 0"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o15" line 2)
(SplitObject unknown line 2)
invoked from within
"$node_($i) random-motion 0 "
("for" body line 3)
invoked from within
"for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns node]
$node_($i) random-motion 0 ;
}"
(file "example2.tcl" line 44)
怎么改啊,这本书上好多错的例子啊。
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns node]
$node_($i) random-motion 0 ;
}
$node_(0) set X_ 5.0
$node_(0) set Y_ 2.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 390.0
$node_(1) set Y_ 386.0
$node_(1) set Z_ 0.0
报错:
$ ns example2.tcl
num_nodes is set 2
(_o15 cmd line 1)
invoked from within
"_o15 cmd random-motion 0"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o15" line 2)
(SplitObject unknown line 2)
invoked from within
"$node_($i) random-motion 0 "
("for" body line 3)
invoked from within
"for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns node]
$node_($i) random-motion 0 ;
}"
(file "example2.tcl" line 44)
怎么改啊,这本书上好多错的例子啊。