CASE statement

Language reference ›› Statements ››
Parent Previous Next

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

PMP implements the standard form of the CASE statement.


<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.

 Ch: char;

 CASE upcase(Ch) OF
   '@', 'A'..'Z':