Hello,
I have a list that I want to sort, but I can't get it right.
The pckt-array has a timestamp and a value on each line and is sorted by the timestamp.
set pcktlst ""
foreach {name value} [array get pckt] {
lappend pcktlst $name $value
}
set pcktlst [lsort -integer -index 0 $pcktlst]
#now...
Hi,
I'm trying to get a boolean value from a procedure, so I can use it for an if-loop:
proc program {
$ns at $now getbool //ns runs the proc @ a certain time
if {$bool == 1} {
do something...
} else {
do something else...
}
}
proc getbool {
set bool 0
set req [expr $x - $y]
if {$req ==...
Does anybody know how this can be solved?
I don't see what's wrong here. :s
for {set i 1} {$i <= 10} {incr i} {
set file "file"
append file $i ".tr"
set chan [open $file]
set lineNumber 0
set tmlst ""
puts "Reads file $i ..."
while {[gets $chan line] >= 0} {
scan $line "%f" time
lappend tmlst...
Does anybody know how I can pass a value from a variable?
for {set i 0} {$i < 3} {incr i} {
if {$i != 0} {
"BGP {$i}"
}
}
proc BGP {x} {
puts $x
}
my compiler says "BGP {$i}" is an invalid command...
what is wrong? thx
ok I changed my code a little bit. For each file I'm reading it needs to store the time stamps in an array. I do it like this:
for {set i 1} {$i <= 10} {incr i} {
set file "file"
append file $i ".tr"
set chan [open $file]
set lineNumber 0
set timearray "time"
append timearray $i
array set...
time should not be a variable, but an array, like:
time1()
time2()
...
the values of those arrays are the timestamps (which are read before from the files).
I like to print some values of those arrays. So I tried the following, before the for-loop:
array set time
but that doesn't work either.
I have 10 files which contain many lines with timestamps. Those timestamps are read and put in arrays beforehand in while-loops like:
set chan [open "file1.tr"]
set lineNumber 0
while {[gets $chan line] >= 0} {
scan $line "%f" time1($lineNumber)
$ns at $time1($lineNumber) "do something"
incr...
Hi,
I'm trying to call serveral procedures in a for-loop, but each cycle of the loop calls another procedure (named procedure0, procedure1,...), like this:
for {set x 0} {$x < 10} {incr x} {
puts "loopcount [expr $x + 1]"
$ns at $x "procedureX"
}
Does someone know how I can do this?
thx
I'm sorry, my mistake, I do have several files:
for {set i 1} {$i <= 3} {incr i} {
set filename "file"
append filename $i ".tr"
....
set chan [open $filename]
set lineNumber 0
while {[gets $chan line] >= 0} {
...
}
close $chan
}
puts "$time2(50) = time value on line 50"
So I need to open...
Thx for your advice! $ns isn't so important here, it's just a variable for my NS-2. It calls a procedure at some time. But I have another problem now.
file.tr consists of lines with those time value. So I'm trying to print some of those values on screen afterwards. My code looks like:
for {set...
I made a mistake with the html-tags, my code looks like:
for {set i 1} {$i <= 3} {incr i} {
set chan [open "file.tr"]
set lineNumber 0
while {[gets $chan line] >= 0} {
scan $line "%f" time1($lineNumber)
$ns at $time1($lineNumber) "procedure"
incr lineNumber
}
close $chan
}
Hi, I have some probs with constructing array-variables in a for-loop. My code looks like this:
for {set i 1} {$i <= 3} {incr i} {
set chan [open "file.tr"]
set lineNumber 0
while {[gets $chan line] >= 0} {
scan $line "%f" time1b($lineNumber)
$ns at $time1($lineNumber) "procedure"
incr...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.