blob: e7a988d26fdaebafa6741c682f97005419999e6c [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001NAME
2 for
3
4SYNTAX
5 for(init; expr2; expr3) statement;
6
7DESCRIPTION
8 Execute <init> once. Then, while <expr2> returns a non-zero
9 value, execute <statement>. Every time <statement> has been
10 executed, or a 'continue' statement has been executed, execute
11 <expr3> before next loop.
12
13 <init> is usually a series of one or more expressions (remember
14 that assignments are expressions, too), separated by commas.
15 Additionally it is also allowed to define new local variables
16 here and assign them an initial value. The scope of such variables
17 is the whole for statement.
18
19 Examples for legal <init> expressions are:
20
21 for (i = 0; ...
22 for (i = 0, j = 0; ...
23 for (i = 0, int j = i; ...
24 for (int j = 4; ...
25
26 Illegal <init> expressions are:
27
28 for (int i; ... : no value assigned
29 for (int i += 4; ... : only plain assignments allowed
30
31 A 'break' in the 'statement' will terminate the loop. A
32 'continue' will continue the execution from the beginning of
33 the loop.
34
35SEE ALSO
36 foreach(LPC), if(LPC), do-while(LPC), while(LPC), switch(LPC)