The for loop is the most general loop construct; while and do while loops are also available, as well as foreach loops.
The LPC for loop is very similar to that provided by C. Syntax is as follows:
for (expression0; expression1; expression2) { statements; ... }
or
for (expression0; expression1; expression2) statement;
expression0 may also be of the form <type> name = ...; in that case a new variable is declared. Currently, the variable is in scope after the loop, however this may change in the future.
expression0 is evaluated once prior to the execution of the loop. expression1 is evaluated at the beginning of each iteration of the loop. If expression1 evaluates to zero, then the loop terminates. expression2 is evaluated at the end of each loop iteration, just before expression1 is evaluated again.
break can be used to exit of for loop prematurely, and continue can be used to immediated evaluate expression2 and go back to the top of the loop.
See also the summary of loops .
Beek @ZorkMUD, Lima Bean, IdeaExchange, TMI-2, and elsewhere