-1
我在TCL以下代碼:如何增加TCL循環中的變量?
set counter 1
for {set i 0} {$i < 3} {incr i 1} {
set temp $counter
incr temp 1
incr counter 2
}
每個循環中,counter
增加2,並且temp
是基於counter
的值增加1,但counter
和temp
值是:
counter 1 temp 2 in the first loop
counter 3 temp 3 in the second loop
counter 5 temp 4 in the third loop
期望值爲:
counter 1 temp 2 in the first loop
counter 3 temp 4 in the second loop
counter 5 temp 6 in the third loop
有什麼問題以及如何解決?
無法重現您所說的內容。你可以在你的代碼中包含'puts'嗎?你可能會錯放他們? – Jerry
你在哪裏檢查$ counter和$ temp的值? – HirofumiTamori
你是否100%確定你在循環中設置了temp,它看起來像你在循環之外設置它。 – KillianDS