CASE statement
CASE statement values must be integer constant expressions. Several values, separated by commas, can lead to the same list of statements. The ELSE statement is optional.
Item | Description |
---|---|
Name | CASE ... OF ... ELSE ... END_CASE |
Meaning | Executes one of several lists of ST statements. Selection is made according to an integer expression. |
Syntax |
|
Example
(* ST program using CASE statement *) CASE error_code OF 255: err_msg := 'Division by zero'; fatal_error := TRUE; 1: err_msg := 'Overflow'; 2, 3: err_msg := 'Bad sign'; ELSE err_msg := 'Unknown error'; END_CASE;
Provide Feedback