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 lineNumber
}
close $chan
}
This while-loop works only for i=1 (see time1)
Now I'm trying to make it more generic (for other values i). How can I do this? I've got something like:
set time "time"
append time $i
while {[gets $chan line] >= 0} {
scan $line "%f%d%n" time($lineNumber)
$ns at $time($lineNumber) "procedure"
incr lineNumber
}
but this isn't working :s
Thx!
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 lineNumber
}
close $chan
}
This while-loop works only for i=1 (see time1)
Now I'm trying to make it more generic (for other values i). How can I do this? I've got something like:
set time "time"
append time $i
while {[gets $chan line] >= 0} {
scan $line "%f%d%n" time($lineNumber)
$ns at $time($lineNumber) "procedure"
incr lineNumber
}
but this isn't working :s
Thx!