CASE statement

Language reference ›› Statements ››
Parent Previous Next

case-statement = CASE case-expression OF
( const-expression | const-range ) { "," ( const-expression | const-range ) } ":"
block
[ ELSE block ]
END .
const-range = const-expression ".." const-expression .


PMP implements the standard form of the CASE statement.


Restrictions:


<case-expression> and <const-expression> should evaluate to a 8-bit result.



NEW! (V2.1): If <case-expression> evaluates to a value wider than 8-bit and its high byte is non-zero, the ELSE block is executed if present, else the entire CASE statement is skipped.


CASE constructions are implemented as a set of compare values or as a jump table, depending on the complexity, to optimize speed and memory.



VAR
 Ch: char;

 CASE upcase(Ch) OF
   '@', 'A'..'Z':
     inc(Result);
   #13:
     writeln;
 END;