[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

#### 8.1.7.4 case Statement

    case expression of
      selector: statement;
      ...
      selector: statement;
    end

or, with alternative statement sequence:

    case ordinal expression of
      selector: statement;
      ...
      selector: statement;
    otherwise                   { ``else'' instead of ``otherwise'' allowed }
      statement;
      ...
      statement;
    end

or, as part of the invariant `record` type definition:

    type
      foo = record
        field declarations
      case bar: variant type of
        selector: (field declarations);
        selector: (field declarations);
        ...
      end;

or, without a variant selector field,

    type
      foo = record
        field declarations
      case variant type of
        selector: (field declarations);
        selector: (field declarations);
        ...
      end;

The `case` statement compares the value of ordinal expression to each selector, which can be a constant, a subrange, or a list of them separated by commata, being compatible with the result of ordinal expression. Note: duplicate selectors or range crossing is not allowed unless {$borland-pascal} is specified. In case of equality the corresponding statement is executed. If `otherwise` is specified and no appropriate selector matched the expression, the series of statements following `otherwise` is executed. As a synonym for `otherwise`, `else` can be used. The semicolon before `otherwise` is optional.

@@ ???? The expression must match one of the selectors in order to continue, unless an alternative statement series is specified.

For `case` in a variant record type definition, see section 8.2.10.4 Record Types.

### See also

section 8.1.7.3 if Statement

This document was generated by Frank Heckenbach on May, 10 2002 using texi2html