Skip to main content

SA0075: Missing ELSE

Detects CASE statements without an ELSE branch

Justification: Defensive programming requires the inclusion of an ELSE branch in every CASE statement. If there is nothing to do in the ELSE branch, then include a comment to indicate this. It is then clear to the reader of the code that the case was not simply forgotten.

Importance: Low

PLCopen rule: L17

Important

For CASE statements which use enumerations with attribute strict and where all enumerations constants are used in the CASE statement is used, no error message is issued.

Example 82. Example
PROGRAM PLC_PRG
VAR
    iVar : INT;
    xTemp : BOOL;
END_VAR
iVar := iVar + INT#1;
CASE iVar OF
    INT#1:
        xTemp := FALSE;
    INT#2:
        xTemp := TRUE;
END_CASE

Output in the Messages view:

  • sa_icon_message.png SA0075: Missing ELSE in CASE statement