If Statement

Expresses branches. If Expr1 is true, SatSeq1 is executed; otherwise, if Expr2 is true, StatSeq2 is executed; if none of the expressions in the if statement is true, StatSeq3 is executed. Multiple elseif parts are allowed. The elseif part and the else part of the if statement are optional.

Syntax

Stat = "if" Expr1 "then" StatSeq1
       { "elseif" Expr2 "then" StatSeq2 }
       [ "else" StatSeq3 ]
       "end".

Example

dcltrans
  transaction TMain
  var
    I, j : number;
    a, b : boolean;
  begin
    if b then
      I := I+1;
      j := j*2
    elseif a then
      I := I-1
    else
      I := I-2
    end;

    if (I < j) and not b then
      b := true;
    end;
  end TMain;