blob: 33bbff20af23760fd658f770aba21c8a19aee0ee [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001NAME
2 if
3
4SYNTAX
5 if (expr1) statement1;
6 else if (expr2) statement2;
7 ...
8 else if (exprN) statementN;
9 else statementX;
10
11DESCRIPTION
12 The if() statement implements the conditional execution of statements.
13 The expressions 'expr1' .. 'exprN' are evaluate in the order they
14 appear until one of the expressions returns non-0 ('true'). At that
15 point, the statement associated with the expression is executed, and
16 the program continues after the if() statement. If none of the
17 expressions evaluate to 'true', the statementX in the 'else'-branch
18 is executed.
19
20 Both the 'else if' branches and the 'else' branch are optional, and
21 there can be any number of 'else if' branches - but there must be one
22 'if' branch, and the branches must be in the order given above.
23
24 Any 'else' or 'else if' always relates to the immediately preceeding
25 'if' resp. 'else if' conditional. This means that
26
27 if (a)
28 if (b) do_b;
29 else do_c;
30
31 is interpreted as
32
33 if (a) {
34 if (b) do_b;
35 else do_c;
36 }
37
38SEE ALSO
39 for(LPC), foreach(LPC), do-while(LPC), while(LPC), switch(LPC)