This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Help for those learning Tcl or writing their own scripts.
jnc_xavier
Voice
Posts: 4 Joined: Sat Aug 20, 2011 8:40 am
Location: India
Post
by jnc_xavier » Sat Aug 20, 2011 8:57 am
when i execute this file i get the error as said below. plz help
Code: Select all
#Create a ns simulator
set ns [new Simulator]
#Open the NS trace file
set tracefile [open out1.tr w]
$ns trace-all $tracefile
#Open the NAM trace file
set namfile [open out1.nam w]
$ns namtrace-all $namfile
#===================================
# Nodes Definition
#===================================
#Create 3 nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
#===================================
# Links Definition
#===================================
#Createlinks between nodes
$ns duplex-link $n0 $n1 100.0Mb 10ms DropTail
$ns queue-limit $n0 $n1 50
$ns duplex-link $n0 $n2 100.0Mb 10ms DropTail
$ns queue-limit $n0 $n2 50
#Give node position (for NAM)
$ns duplex-link-op $n0 $n1 orient right-down
$ns duplex-link-op $n0 $n2 orient right-down
#===================================
# Agents Definition
#===================================
#===================================
# Applications Definition
#===================================
#===================================
# Termination
#===================================
#Define a 'finish' procedure
proc finish {}
{
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam -a out1.nam &
exit 0
}
$ns at 10.0 "finish"
$ns run
ERROR THAT SHOWS UP:
wrong #args: should be "proc name args body"
while executing
"proc finish {}"
(file wired2node.tcl line 71)
Jan Xavier
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Sat Aug 20, 2011 9:07 am
In tcl, all arguments must be on the same line (though each argument may contain newlines)
Thus, this is incorrect:
The proper code would look like this:
NML_375
jnc_xavier
Voice
Posts: 4 Joined: Sat Aug 20, 2011 8:40 am
Location: India
Post
by jnc_xavier » Sat Aug 20, 2011 9:27 am
but that too aint working. could u plz help
Jan Xavier
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Sat Aug 20, 2011 9:32 am
Changing the definition of "finish" into this:
Code: Select all
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam -a out1.nam &
exit 0
}
Should sort the posted error message. Please post any new error messages you get.
NML_375
sh.minaee
Voice
Posts: 1 Joined: Sun Mar 02, 2014 2:12 am
Post
by sh.minaee » Sun Mar 02, 2014 2:17 am
I've did that, but this time i have this error :
ns: finish: wrong # args: should be "close channelId"
while executing
"close $tracefile # close tracefile"
(procedure "finish" line 5)
invoked from within
"finish"
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Sun Mar 02, 2014 11:16 am
Remove the comment (# close tracefile) from your code...
Or prefix the # with a ;
Such as this:
Code: Select all
...
close $tracefile ;# close tracefile
NML_375