Inst ToolsInst ToolsInst Tools
  • Courses
  • Automation
    • PLC
    • Control System
    • Safety System
    • Communication
    • Fire & Gas System
  • Instrumentation
    • Design
    • Pressure
    • Temperature
    • Flow
    • Level
    • Vibration
    • Analyzer
    • Control Valve
    • Switch
    • Calibration
    • Erection & Commissioning
  • Interview
    • Instrumentation
    • Electrical
    • Electronics
    • Practical
  • Q&A
    • Instrumentation
    • Control System
    • Electrical
    • Electronics
    • Analog Electronics
    • Digital Electronics
    • Power Electronics
    • Microprocessor
  • Request
Search
  • Books
  • Software
  • Projects
  • Process
  • Tools
  • Basics
  • Formula
  • Power Plant
  • Root Cause Analysis
  • Electrical Basics
  • Animation
  • Standards
  • 4-20 mA Course
  • Siemens PLC Course
Reading: Case Statement in SCL Language
Share
Font ResizerAa
Inst ToolsInst Tools
Font ResizerAa
  • Courses
  • Design
  • PLC
  • Interview
  • Control System
Search
  • Courses
  • Automation
    • PLC
    • Control System
    • Safety System
    • Communication
    • Fire & Gas System
  • Instrumentation
    • Design
    • Pressure
    • Temperature
    • Flow
    • Level
    • Vibration
    • Analyzer
    • Control Valve
    • Switch
    • Calibration
    • Erection & Commissioning
  • Interview
    • Instrumentation
    • Electrical
    • Electronics
    • Practical
  • Q&A
    • Instrumentation
    • Control System
    • Electrical
    • Electronics
    • Analog Electronics
    • Digital Electronics
    • Power Electronics
    • Microprocessor
  • Request
Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Inst Tools > Blog > PLC Tutorials > Case Statement in SCL Language

Case Statement in SCL Language

Explore the Case Statement in SCL language and learn how it simplifies coding for selection-based programs.

Last updated: March 25, 2025 2:29 pm
Viral Nagda
PLC Tutorials
No Comments
Share
4 Min Read
SHARE

In the previous post, we saw how to write an if else statement in SCL language. The next construct we are going to use is case statement. This Case statement is used widely for selection-based programs, which helps in reducing code size if an if else statement was used. So, studying case statements is a very integral part of learning ST language. In this post, we will see the use of case statements in SCL language.

Contents
What is a case statement?How to write a case statement in SCL language?

What is a case statement?

A case statement is a construct which is used to execute statements inside it based on the various types of cases or values. That means, if there are 10 cases, then when a current case value matches the set case value, the corresponding statements inside that set case are executed. This is useful when you have various criteria and want to execute a criteria depending on the current condition. If case statement is not used, then you can use an if else statement too here, but the program coding will be increased and also the complexity.

The general syntax of case statement is :

Case var of

1: statement;

2: statement;

3: statement;

..

N: statement;

end_case;

Here, the var refers to a variable which takes a value and depending on that value, the statements matching that case value are executed. Means if the current value is 2, then the statements under case-2 will be executed.

How to write a case statement in SCL language?

Now that we have understood the basics, let us write a sample logic using a case statement. Refer to the below image, where we compare it with an if else statement. The logic is – if the value of variable I_Pv is 34, then we add 1 with the value of var_2 and move the answer to var_1; and if the value of variable I_Pv is 35, then we add 1 with the value of var_3 and move the answer to var_1.

Case Statement in SCL Language

In the first scenario, we used an if-else statement. In the first if-else construct, we write the logic for comparing I_Pv with 34. In the second if-else construct, we write the logic for comparing I_Pv with 35. Then, whichever condition is true, the corresponding addition is done inside them. Due to this, our logic is executed.

But if we see the second scenario, we used a case statement. Here, as per the general syntax mentioned earlier, we use the case of I_Pv as reference value. The statement monitors the current value of this variable, and if the value is 34, then the addition written under 34: is executed; and if the value is 35, then the addition written under 35: is executed. Then, we terminate the construct with the end_casekeyword.

If there are a large number of such comparisons, then instead of writing an if or if else multiple times, we can simply use a case statement for solving the issue. Our coding size reduces and the program too looks easier to troubleshoot.

In the next post, we will see how to use a for do statement in SCL language.

Read Next:

  • Types of Expressions in the SCL Language
  • Mail Box Automation: Programming with PLC
  • PLC Hoist Crane Programming Example
  • PLC Mixing Process with Timer and Valve Control
  • PLC Programming for Loss in Weight Liquid Systems
Don't Miss Our Updates
Be the first to get exclusive content straight to your email.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address
You've successfully subscribed !

Continue Reading

PLC Logic: Control Spray Nozzle, Fans, and Puncher
Program Flow Control Instructions in PLC Programming
Sheets, Tags, Elements in Functional Block Diagram of Studio 5000
PLC Selective Execution of the Application – Example Program
How to Troubleshoot a PLC System?
Free Industrial Control System (ICS) Cyber Security Training Course
Share This Article
Facebook Whatsapp Whatsapp LinkedIn Copy Link
Share
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

128.3kFollowersLike
69.1kFollowersFollow
210kSubscribersSubscribe
38kFollowersFollow

Categories

Explore More

PLC Program for 2 Push buttons to Control 1 Output
PLC Programming to Control Lights in a Sequence
Controlling of Tank Level Using Proportional Controller in PLC
PLC Program for Alarm Indication in Process Control
Motor Trip Logic using PLC Programming
Cloud-Based SCADA Projects – Try Free Demo Account
Types of Interlocks
Open Loop and Closed Loop System Questions Answers

Keep Learning

Siemens PLC Organization Blocks used For Troubleshooting

Tia Portal – OB121 Programming Errors Interrupt Organization Block

PLC Automation for Product Weighing and Labeling

PLC Controlled Conveyor and Weighing with Labeling Automation

Manual sequential logic in Schneider PLC

Programming Schneider PLC Manual Sequential Machine

Basic PLC Alarm Programming Example

Basic PLC Alarm Programming Example

IP Address Change in Simatic

PLC Configuration of Profinet I/O System

DCS

DCS

PLC Program for Temperature Control using Thermostat

PLC Program for Temperature Control using Thermostat

Data Types in PLC

Data Types in PLC – Bit, Byte, Integer, Real, String

Learn More

RTD

Why 4 wire RTD Measurement Accuracy is better than 2 and 3 wire RTD?

Convert 4-20ma current output to foundation fieldbus

Download Free Robotics Software

Step by Step Guidelines to Download Free Robotics Software

Electrical Machines Questions and Answers

Rotating Machines Objective Questions

Digital Electronics Multiple Choice Questions

Registers Objective Questions

Brushed DC Motor Working Animation

Brushed DC Motor Working Animation

Load Cell Design

How to select a load cell?

Free WinCC SCADA Training Course

Free SCADA Training Course

Menu

  • About
  • Privacy Policy
  • Copyright

Quick Links

  • Learn PLC
  • Helping Hand
  • Part Time Job

YouTube Subscribe

Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?