This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

how do I do loops

Old posts that have not been replied to for several years.
Locked
t
tom^

Post by tom^ »

Wanted to execute some statements in a proc a certain number of times until a max counter is reached. What am I missing in the following because it only loops once only and I wanted to execute some statements 5 times.

proc loop
set countbeg 0
set countmax 5

while { $countbeg < $countmax } {
incr countbeg
statements to execute...
}

Thanks tom^
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

looks fine to me. Maybe an error or a break statement is dropping it out of the loop...
W
Wcc
Master
Posts: 278
Joined: Sun Oct 28, 2001 8:00 pm
Location: USA
Contact:

Post by Wcc »

It would probably save code to use a for loop:

Code: Select all

proc loop {} {
  for {set i 0} {$i < 5} {incr i} { 
    statements to execute
  } 
}
Locked