Control statements in LPC: In all the following examples <statement> is either a single expression or function call or it's a block of statements enclosed in { } An expression is considered false in lpc _only_ if it es equal to the number zero, in all other caseses it is consider true. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: STATEMENT if - else - run on condition SYNOPSIS if( expression ) <statement> or if( expression ) <statement> else <statement> DESCRIPTION If is the simplest of all control structures, in the first form it runs the statement if the expression is true and in the second form it runs the first statement if the expression is true and the second if it is false. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: STATEMENT for - general loop statement SYNOPSIS for ( expression1 ; expression2 ; expression3 ) <statement> DESCRIPTION the above statement is exactly equal to: expression1; while( expression2 ) { <statement> expression3; } EXAMPLE int e; for(e=0;e<10;e++) write(e+"\n"); SEE ALSO while ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: STATEMENT while - execute a statement while an expression is true SYNOPSIS while( expression ) <statement> DESCRIPTION While runns the statement until the expression is false. The expression is evaluated once for every loop. If the expression is false the first time the statement is never executed. SEE ALSO for, do - while ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: STATEMENT do - while - execute a statement while an expression true SYNOPSIS do <statement> while ( expression ); DESCRIPTION do - while only differs from the ordinary while-loop in that it does _not_ evaluate the expression until after the statement has been executed once. Thus it always runs the statement once. SEE ALSO do - while ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: STATEMENT switch - case - Complicated conditional statement SYNOPSIS switch( expression ) { case constant1: <statement1> case constant2: <statement2> break; default: <statement3> } DESCRIPTION Switch evaluates the expression give and then executes one or more statement accordingly to the result. If the result is equal to constant1 then statement1 will be executed, please observe that the second case-statement dos _not_ abort the execution in any way instead statement2 will also be executed. After that break will cause execution to continue after the after the last } in the switch statement. If the result is equal to constant2 only statement2 will be executed. In all other cases statement3 is executed because it is 'default'. Please note that the expression and constant can be either integers or string, but they can _not_ be mixed in the same switch-statement. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: STATEMENT break - break a loop or switch SYNOPSIS break; DESCRIPTION Break jumps directly out of any loop or switch statement, it is a very vital part of every switch statement. SEE ALSO do - while, while, for, switch ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: STATEMENT continue - continue a loop SYNOPSIS continue; DESCRIPTION Continue work similarly to break only it does't finish the loop, it just aborts the rest of this turn in the loop. BUGS Don't use it in conjunction with the switch-statement. SEE ALSO do - while, while, for ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: STATEMENT return - return from a function SYNOPSIS return; or return expression; DESCRIPTION Return jumps directly out of a function returning the given value to the calling function. If no expression is given, 0 is returned. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::