If

From Lazarus-ccr

Jump to: navigation, search

This keyword preciedes a condition, is required to be followed by then and may be followed by else.

[edit] If then

 
  if condition
    then action1
    else action2;
 

Condition is an expression that evaluates to true or false. Action1 is executed if condition evaluates to true. Action2 is executed if condition evaluates to false.

[edit] More statements in "if then" statement

If you need two or more statements in "if then" statement. In that case, you need the begin ... end around the statements.

 
  if boolean_condition then
    begin
      statement_one;
      statement_two;
      statement_three;
    end;
 



Keywords: begindoelseendforifrepeatthenuntilwhile