-@node Conditionals and Looping, Statistics, Data Selection, Top
+@node Conditionals and Looping
@chapter Conditional and Looping Constructs
@cindex conditionals
@cindex loops
* LOOP:: Repeat a block of code.
@end menu
-@node BREAK, DO IF, Conditionals and Looping, Conditionals and Looping
+@node BREAK
@section BREAK
@vindex BREAK
@cmd{BREAK} is allowed only inside @cmd{LOOP}@dots{}@cmd{END LOOP}.
@xref{LOOP}, for more details.
-@node DO IF, DO REPEAT, BREAK, Conditionals and Looping
+@node DO IF
@section DO IF
@vindex DO IF
(@pxref{TEMPORARY}), the @cmd{LAG} function may not be used
(@pxref{LAG}).
-@node DO REPEAT, LOOP, DO IF, Conditionals and Looping
+@node DO REPEAT
@section DO REPEAT
@vindex DO REPEAT
are made are printed to the listing file, prefixed by a plus sign
(@samp{+}).
-@node LOOP, , DO REPEAT, Conditionals and Looping
+@node LOOP
@section LOOP
@vindex LOOP
condition is false or missing before the loop contents are executed the
first time, the loop contents are not executed at all.
-If index and condition clauses are both present on @cmd{LOOP}, the index
-clause is always evaluated first.
+If index and condition clauses are both present on @cmd{LOOP}, the
+index variable is always set before the condition is evaluated. Thus,
+a condition that makes use of the index variable will always see the
+index value to be used in the next execution of the body.
Specify a boolean expression for the condition on @cmd{END LOOP} to cause
-the loop to terminate if the condition is not true after the enclosed
+the loop to terminate if the condition is true after the enclosed
code block is executed. The condition is evaluated at the end of the
-loop, not at the beginning.
+loop, not at the beginning, so that the body of a loop with only a
+condition on @cmd{END LOOP} will always execute at least once.
-If the index clause and both condition clauses are not present, then the
-loop is executed MXLOOPS (@pxref{SET}) times.
+If neither the index clause nor either condition clause is
+present, then the loop is executed MXLOOPS (@pxref{SET}) times.
@cmd{BREAK} also terminates @cmd{LOOP} execution (@pxref{BREAK}).