Library /sys$common/syshlp/helplib.hlb  —  PASCAL  Statements  IF_THEN_ELSE
  The IF statement tests  a  Boolean  expression  and  performs  a
  specified  action  if  the result of the test is TRUE.  The ELSE
  clause, when it appears, executes only  if  the  test  condition
  results to FALSE.

  Syntax:

     IF boolean-expression THEN statement1 [[ELSE statement2]]

  The 'boolean-expression' is any Boolean expression.

  The 'statement1' is the statement to be executed if the value of
  the Boolean expression is TRUE.

  The 'statement2' is the statement to be executed if the value of
  the Boolean expression is FALSE.

  VSI Pascal may not always evalutate all the terms of  a  Boolean
  expression if it can evaluate the entire expression based on the
  value of one term.  Either do not write  code  that  depends  on
  actual  evalution  (or evaluation order) of Boolean expressions,
  or use the AND_THEN and  OR_ELSE  operators  for  a  predictable
  order of evaluation.

1  –  Examples

     IF x > 10 THEN y := 4           IF x > 10 THEN BEGIN y := 4;
               ELSE y := 5;                               z := 5;
                                                    END
                                               ELSE y := 5;

  The ELSE clause always modifies the closest IF-THEN statement.

  Use caution to avoid logic errors in nested IF statements, as in
  the following:

     IF A = 1 THEN    {First IF}
        IF B<>1 THEN  {Second IF}
           C := 1
     ELSE             {Appears to modify first IF}
        C := 0;       {Actually modifies second IF}
Close Help