Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


double loop

double loop

double loop

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.


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

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


RE: double loop

Thanks feherke for the quick reply - now  I  also understand the error message : )

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close