Case statements are a type of control statement that can be used as alternatives to if-then-else constructs. Case statements have the following general form:

 

    case control_expression is

        when test_expression1  =>

            statements

        when test_expression2  =>

            statements

        when others  =>

            statements

    end case;

 

The test expressions of a case statement must be mutually exclusive, meaning that no two test expressions are allowed to be true at the same time.  Case statements must also include all possible conditions of the control expression. (The others expression can be used to guarantee that all conditions are covered.)

 

The primary difference between descriptions written using case statements from those written using if-then-else statements is that if-then-else statements imply a priority of conditions, while a case statement does not imply any priority. (This is similar to the difference between the conditional and selected assignments described in the section Concurrent Statements.)

 

See also

image\diamond.gif  If-Then-Else Statements

image\diamond.gif  Sequential Statements