if StatementThe if statement allows conditional execution of a statement or a conditional choice of two statements, executing one or the other but not both.
IfThenStatement:
if (Expression)Statement IfThenElseStatement:
if (Expression)StatementNoShortIfelseStatement IfThenElseStatementNoShortIf:
if (Expression)StatementNoShortIfelseStatementNoShortIf
The Expression must have type boolean, or a compile-time error occurs.
if-then StatementAn if-then statement is executed by first evaluating the Expression. If evaluation of the Expression completes abruptly for some reason, the if-then statement completes abruptly for the same reason. Otherwise, execution continues by making a choice based on the resulting value:
true, then the contained Statement is executed; the if-then statement completes normally only if execution of the Statement completes normally.false, no further action is taken and the if-then statement completes normally.if-then-else StatementAn if-then-else statement is executed by first evaluating the Expression. If evaluation of the Expression completes abruptly for some reason, then the if- then-else statement completes abruptly for the same reason. Otherwise, execution continues by making a choice based on the resulting value:
true, then the first contained Statement (the one before the else keyword) is executed; the if-then-else statement completes normally only if execution of that statement completes normally.false, then the second contained Statement (the one after the else keyword) is executed; the if-then-else statement completes normally only if execution of that statement completes normally.