DELPHI: Selection / Decision Making
 

Decision making in Delphi is determined using IF and CASE statements. Below are some examples of coding frameworks:


Basic IF statement

IF <condition(s)> THEN
BEGIN
  <statements>
END;


IF Statement with an ELSE

IF <condition(s)> THEN
BEGIN
  <statements>
END
ELSE {If the top condition is not met then?}
BEGIN
  <statements>
END;

IF <condition(s)> THEN
BEGIN
  <statements>
END
ELSE
IF <condition(s)> THEN
BEGIN
  <statements>
END
ELSE {If the top conditions are not met then?}
BEGIN
  <statements>
END;


Additional logical operators can also be added: AND, OR, NOT (use brackets around conditions)


CASE statement

CASE <selection statement> OF
  <value1> := <statement(s)>;
  <value2> := <statement(s)>;
  <value3> := <statement(s)>;
ELSE
<statement(s)>
END;

 

Return to Delphi resources index




Return to Home Page

? 2024 J Olivier. Except where otherwise noted, the content on this website is licensed under the terms of the Creative Commons BY SA 4.0 license. https://creativecommons.org/about/cclicenses/