Difference between revisions of "Else"
From Lazarus wiki
Jump to navigationJump to searchm |
|||
Line 1: | Line 1: | ||
− | + | Else is [[Keyword|keyword]] which introduces the action to do if the condition is [[False|false]]. | |
+ | |||
+ | = If then else = | ||
+ | <delphi> | ||
if (condition) | if (condition) | ||
then (action) | then (action) | ||
else (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|begin]] ... [[End|end]] around the statements. | ||
+ | |||
+ | <delphi> | ||
+ | if boolean_condition then | ||
+ | begin | ||
+ | statement_one; | ||
+ | statement_two; | ||
+ | end | ||
+ | else | ||
+ | begin | ||
+ | statement_three; | ||
+ | statement_four; | ||
+ | end; | ||
+ | </delphi> | ||
+ | |||
{{Keywords}} | {{Keywords}} |
Revision as of 19:22, 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: begin — do — else — end — for — if — repeat — then — until — while