for {set count 0} {$count<$num_of_UEs} { incr count } {
puts $count
set tcp$count [new Agent/TCP]
#$tcp$count set fid_ $count
#$tcp$count set prio_ 2
}
Моя проблема со строкой #$tcp$count set fid_ $count
Когда я пытаюсь выполнить ее, она говорит
can't read "tcp": no such variable
while executing
"$tcp$count set fid_ $count"
("for" body line 4)
invoked from within
"for {set count 0} {$count<$num_of_UEs} { incr count } {
puts $count
set tcp$count [new Agent/TCP]
$tcp$count set fid_ $count
$tcp$coun..."
Он говорит, что не может прочитать tcp, ну, он не должен читать tcp, он должен прочитать его как tcp0 в первой итерации и tcp1 во второй и так далее.
Что я делаю не так?
спасибо
EDIT:
Я пытался использовать массивы, спасибо за СОВЕТ. Это работало для большинства частей, но в одном конкретном случае
когда я сделал это:
for {set count 0} {$count<$num_of_UEs} { incr count } {
set ftp($count) [new Application/FTP]
$ftp($count) attach-agent $tcp($count)
}
Это дает мне следующую ошибку:
Came here 0
(_o180 cmd line 1)
invoked from within
"_o180 cmd target _o99"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o180" line 2)
(SplitObject unknown line 2)
invoked from within
"$agent target [[$self node] entry]"
(procedure "_o98" line 2)
(RtModule attach line 2)
invoked from within
"$m attach $agent $port"
(procedure "_o97" line 4)
(Node add-target line 4)
invoked from within
"$self add-target $agent $port"
(procedure "_o97" line 15)
(Node attach line 15)
invoked from within
"$node attach $agent"
(procedure "_o3" line 2)
(Simulator attach-agent line 2)
invoked from within
"$ns attach-agent $node2 $tcp($count)"
("for" body line 3)
invoked from within
"for {set count 0} {$count<$num_of_UEs} { incr count } {
puts "Came here $count"
$ns attach-agent $node2 $tcp($count)
}"
(file "hsexample.tcl" line 104)
Я знаю, это долго, но я был бы очень признателен за вашу помощь