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
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
Notification Show More
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
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

Introducing PLC Programming using LogixPro Simulator Software
PLC Count values higher than 999
Loop Check of 4-20mA or HART Transmitters
Introduction to PLC – Advantages of PLC
PLC Program for Bank Counter Application
AI, AO, DI, DO Questions (PLC I/O Types)
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
208kSubscribersSubscribe
38kFollowersFollow

Categories

Explore More

PLC System Site Acceptance Test (SAT)
MCQ on PLC (Programmable Logic Controller)
PID Simulator Download
Medium-Level PLC Exercise for Students in Automation
One Shot Rising PLC Example Program
Tia Portal – OB20 Time Delay Interrupt Organization Block
Safety PLC Coding Practices – Programming Recommendations
How to Read an Electrical Wiring Diagram?

Keep Learning

Multi Way Switches using PLC

Making Multi Way Switches using PLC

Relay Wiring

Animation of Electromagnetic Relay

PLC Timer Program

PLC Timer Instructions

What is Hot Standby in PLC

What is Hot Standby in PLC?

Software Troubleshooting Errors and Faults in Siemens PLC

Software Troubleshooting Errors and Faults in Siemens PLC

Instruction List in PLC Programming

What is an Instruction List? – PLC Programming

Distributed IO for Siemens PLC

How to Configure Distributed IO in a PLC Project?

PLC Program for Counting Objects on Conveyor

PLC Program for Counting Moving Objects on Conveyor

Learn More

Wiring-Connection-from-PLC-to-Solenoid-Valves

How to Connect a Solenoid Valve with PLC?

liquid flow control loop

Liquid Flow Control Loop Controller Action

Polyvinyl Alcohol in Oil Field

Polyvinyl Alcohol in Oil Field

Synchronous Motor Is Not Self Starting?

refrigeration compressors

Why is CO2 the Most Promising Refrigerant in Cooling Industry?

PLC Memory Mapping

PLC Memory Mapping and I/O addressing

Motor Control On-Delay Timers Circuit

Motor Control Timer Circuit – Automatic Motor START and STOP

Flow Meter Questions and Answers

Flow Meter Questions and Answers

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?