Difference between revisions of "If and Then"

From Lazarus wiki
Jump to navigationJump to search
(language. BTW: the "an error occurs" line is vague. Run-time? Design-time? Error? What number? Exception?)
Line 1: Line 1:
 
{{If}}
 
{{If}}
  
This [[Keyword|keyword]] precedes a condition, is required to be followed by [[Then|then]] and may optionally be followed by [[Else|else]].
+
This [[Keyword|keyword]] precedes a condition, must be followed by [[Then|then]] and may optionally be followed by [[Else|else]].
  
 
== If then ==
 
== If then ==

Revision as of 13:35, 27 June 2014

English (en)

This keyword precedes a condition, must be followed by then and may optionally be followed by else.

If then

  if condition
    then true_statement
    else false_statement;

Condition is a Boolean expression that evaluates to true or false. true_statement is executed if condition evaluates to true. false_statement is executed if condition evaluates to false. An error occurs if condition does not evaluate to a boolean value.


More statements in "if then" statement

If you need two or more statements for true_statement or false_statement, place them within a begin ... end Block.

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



Keywords: begindoelseendforifrepeatthenuntilwhile