tcl error extra characters after close-brace while executing for

ns2
user3146469 picture user3146469 · Feb 26, 2015 · Viewed 9.4k times · Source
set ns [new Simulator]
#open nam file
set nf [open out.nam w]
$ns namtrace-all $nf
#set variables of topology
set lanNodes 5
set link("bandwidth") 5mb
set link("delay") 2ms
set link("queue") DropTail
#define two routers
set router0 [$ns node]
set router1 [$ns node]
#link two routers
$ns duplex-link $router0 $router1 2mb 2ms DropTail
#create and connect nodes with routers
for {set i 0}{$i < $lanNodes}{incr i} {
set n($i) [$ns node]
set n([expr $i+5]) [$ns node]
$ns duplex-link $n($i) $router0 $link("bandwidth") $link("delay") $link("queue")
$ns duplex-link $n([expr $i+5]) $router1 $link("bandwidth") $link("delay") $link("queue")
}
proc finish { } {
global ns nf
close $nf

what is error for this code when i want to implemented this code in ns2 write this sentences " extra characters after close-brace while executing for " what is meaning and who can solve this

Answer

Knud Larsen picture Knud Larsen · Feb 26, 2015

Please try editing (line 16)

for {set i 0}{$i < $lanNodes}{incr i} {

To :

for {set i 0} {$i < $lanNodes} {incr i} {

i.e. add a space after each close-brace ( } )

-