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.
Properties of CASE statement
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
CASE <integer_expression> OF <value> : <statement1> ; <statement2> ; <statementsN> <value> : <statements> ; <value>, <value> : <statements>; ... ELSE <statements> ; END_CASE;

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
Have questions or feedback about this documentation? Please submit your feedback here.
Normal