VMS Help  —  PASCAL  Statements  CASE
  The CASE statement  causes  one  of  several  statements  to  be
  executed.   The  execution  depends  on  the value of an ordinal
  expression called the case selector.

  Syntax:

     CASE case-selector OF
          [[{{case-label-list},... : statement};...]]
          [[ [[;]] OTHERWISE {statement};...]]
          [[;]]
         END

  The 'case-selector' is an expression of an ordinal type.

  The 'case-label-list' is one or more case  labels  of  the  same
  ordinal  type as the case selector, separated by commas.  A case
  label can be a single constant expression, such as 1, or a range
  of expressions, such as 5..10.

  The 'statement' is any statement to be executed depending on the
  values of both the case-selector and the case-label.

  The 'OTHERWISE' clause is executed if  the  value  of  the  case
  selector  does  not  appear  in the case label list.  This is an
  optional clause, but if you omit  it,  the  value  of  the  case
  selector must be equal to one of the case labels.

1  –  Examples

     CASE CH OF
         ' ',TAB :  WRITELN( 'Found a space' );
         '0'..'9':  WRITELN( 'Found a digit' );
         'A'..'Z':  WRITELN( 'Found a capital letter' );
         OTHERWISE
                    WRITELN( 'Illegal character' );
     END;

  At run time, the system evaluates the  case  selector  'CH'  and
  executes  the  corresponding statement.  If the value of 'CH' is
  not equal to ' ', '0'..'9' or 'A'..'Z',  the  statement  in  the
  'OTHERWISE' clause is executed.
Close Help