farm ostrich
farm ostrich

Reputation: 5959

How to do += in TCL

set windowSize 0

for {set i 0} {$i < 14} {incr i} {
  set $windowSize [expr $windowSize + [$tcp($i) set cwnd_]]
}
puts "$windowSize"

This prints out zero, when the values being added are non zero. How to do this without a temp var? Holla if you love TCL. ...dead silence.

Upvotes: 1

Views: 1363

Answers (1)

Andy
Andy

Reputation: 4866

set $windowSize substitutes the value of $windowSize before running the command.

You want set windowSize [expr ...], or even simpler:

incr windowSize [$tcp($i) set cwnd_]

Upvotes: 7

Related Questions