CASE Statement
CASE values must be integer constant expressions. Several values, separated by commas, can lead to the same list of statements. The ELSE statement is optional.
CASE Statement | |
---|---|
Name | CASE ... OF ... ELSE ... END_CASE |
Meaning | executes one of several lists of ST statements |
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;
To insert a CASE
- From theToolbox, drag theCASEelement into the language container.
Provide Feedback