#set TITLE = "loops"
#include top

.SH Looping
\fC#while\fR, \fC#for\fR, and basic loops are supported.
All types use \fC#endloop\fR to signify the end of the loop body.
Loops can be nested.

#include space

.SH #while
Loop the flow of control while a
#set FILE = condex.html
#set TAG = conditional expression
#include link
is true.
If the expression is initially false, the loop body will not be executed at all.
.LP
Example: Loops until I exceeds 10:
.LP
.nf
\0#set I = 0
\0#while @I <= 10
\0  #set I = $arith(@I+1)
\0#endloop
.fi

#include space

.SH #for .. in ..
Loop the flow of control, iterating across members of a
#set FILE = "commalist.html"
#set TAG = "comma-delimited list"
#include link
If the list is empty, the loop body will not be executed.
.LP
Example: suppose \fCmset\fR contains a list.
.nf
\0#for M in @@mset
\0  ...
\0#endloop
.fi

#include space

.SH #for .. across ..
.LP
Loop the flow of control, iterating across members of
a \fImultirow-response\fR to a <SELECT MULTIPLE> HTML form item.
No leading at-sign should be used on the variable names.
\fIvar\fR will be set to each member from first to last.
If no lines were selected, the loop body will not be executed.
.LP
Example: suppose \fCcategories\fR is the response to a \fC<SELECT MULTIPLE>\fR box.
.nf
\0#for M across categories
\0  ..
\0#endloop
.fi

#include space


.SH #loop
.LP
Loop the flow of control.  \fC#break\fR \fBmust\fR be used to terminate the loop.
.LP
Example: Loops until I exceeds 10:
.LP
.nf
\0#set I = 0
\0#loop
\0   #set I = $arith(@I+1)
\0   #if @I > 10
\0       #break
\0   #endif
\0#endloop
.fi

#include space

.SH #break
Terminate the iteration of the most recently invoked loop.
Script execution resumes at the statement immediately following
the corresponding \fC#endloop\fR.
There are restrictions if used within an 
#set FILE = "flow.html"
#set TAG = "#included"
#include link
file.

#include space

.SH #continue
Proceed directly to the next
iteration of the most recently invoked loop.
There are restrictions if used within an 
#set FILE = "flow.html"
#set TAG = "#included"
#include link
file.

#include bottom
