if Statement


The if statement is used to make a decision based on whether an expression evaluates to true or false. The decision determines what program statement is executed next. When expression evaluates to a non-zero value (true), the executable program statement immediately following the expression executes. When expression evaluates to 0 (false), the executable program statement immediately following the else statement is executed. When the chosen executable statement finishes, control flows to the next statement after the if statement. The else component of the if statement is optional.

Only one executable program statement can be inserted after the if expression or else statement. If multiple executable program statements are required, enclose them in curly braces {} to make a single compound statement.


if (expression)
executable program statement;
executable program statement;
# Make an accept or reject decision based on
# CurrentUserType
if (CurrentUserType == 1)
   # if CurrentUserType is equal to 1, do these statements
   RunCheck = true;
   # if CurrentUserType is not equal to 1, perform these statements:
   RunCheck = false;

For more information, please see switch Statement.