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 lineNumber
}
set chan [open "file2.tr"]
...
Later on, I try to call the values of those arrays, but in a generic manner:
for {set x 1} {$x <= 10} {incr x} {
set time "time"
append time $x
puts "file $x :"
puts " line 50 = $time(50)
}
but this doesn't seem to work because $time isn't an array here...
How can I do this?
thanks
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 lineNumber
}
set chan [open "file2.tr"]
...
Later on, I try to call the values of those arrays, but in a generic manner:
for {set x 1} {$x <= 10} {incr x} {
set time "time"
append time $x
puts "file $x :"
puts " line 50 = $time(50)
}
but this doesn't seem to work because $time isn't an array here...
How can I do this?
thanks