Difference between revisions of "Else"

From Lazarus wiki
Jump to navigationJump to search
Line 1: Line 1:
 
Else is [[Keyword|keyword]] which introduces the action to do if the condition is [[False|false]].
 
Else is [[Keyword|keyword]] which introduces the action to do if the condition is [[False|false]].
  
= If then else =
+
= [[If]] [[Then|then]] else =
 
<delphi>
 
<delphi>
 
   if (condition)
 
   if (condition)

Revision as of 19:23, 17 October 2007

Else is keyword which introduces the action to do if the condition is false.

If then else

<delphi>

 if (condition)
 then (action)
 else (action);

</delphi>

More statements in "if then else" statement

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

<delphi>

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

</delphi>



Keywords: begindoelseendforifrepeatthenuntilwhile