for { init } { test } { next } { body }
. The examples below shows for loops with more than one variables:
- Example 1:
for { set i 0; set j 10 } { $i < $j } { incr i; incr j -1 } { puts "$i $j" }
Output:0 10 1 9 2 8 3 7 4 6
- Example 2:
for { set i 0; set j 10 } { $i < 3 && $j < 7 } { incr i; incr j -1 } { puts "$i $j" }
Output:0 10 1 9 2 8
No comments:
Post a Comment