## double loop

## double loop

(OP)

Hi all,

Because of getting tired of editing ini files I wanted to write a small prog helping me.

I have to make a list of several instruments and runs. I tried:

set maxtape 10

set maxsite 10

for { set i 1 } { $i <= $maxsite } { incr i } {

set j 0

for { set j 1 } { $j <= $maxtape } { incr j } {

puts " $i and $j "

} # for j

} # for i

I also tried a combination of while and for - also not working

set i 0

while { $i <= $maxsite } {

# puts "i is $i "

for { set j 1 } { $j <= $maxtape } { incr j } {

puts " $i and $j "

} # for j

set i [expr {$i + 1}]

}

I always get the following error:

Error in startup script: wrong # args: should be "for start test next command"

What am I doing wrong? Is it simply not possible to have a double loop?

If not how would I solve it? Thanks in advance.

Eide

Because of getting tired of editing ini files I wanted to write a small prog helping me.

I have to make a list of several instruments and runs. I tried:

set maxtape 10

set maxsite 10

for { set i 1 } { $i <= $maxsite } { incr i } {

set j 0

for { set j 1 } { $j <= $maxtape } { incr j } {

puts " $i and $j "

} # for j

} # for i

I also tried a combination of while and for - also not working

set i 0

while { $i <= $maxsite } {

# puts "i is $i "

for { set j 1 } { $j <= $maxtape } { incr j } {

puts " $i and $j "

} # for j

set i [expr {$i + 1}]

}

I always get the following error:

Error in startup script: wrong # args: should be "for start test next command"

What am I doing wrong? Is it simply not possible to have a double loop?

If not how would I solve it? Thanks in advance.

Eide

## RE: double loop

In Tcl the comments can be placed only at the beginning of commands. So you have to terminate the for before the #, either by placing a new-line or a semicolon ( ; ) between them :

## CODE --> Tcl

set j 0

for { set j 1 } { $j <= $maxtape } { incr j } {

puts

" $i and $j "}; # for j

}; # for i

Feherke.

## RE: double loop