Use of Comments in SCL Language

In an earlier post we saw how to write a while do statement. It is particularly important if we are executing repetitive statements. Now, apart from executing and writing statements, the SCL language provides one more option to bypass the statements if not required. It is called a comment. A comment is used to add descriptions to a line or bypass statements. Programmers can make very good use of this feature, which helps in reducing troubleshooting time. In this post, we will see how to use comments in SCL language.

What is a comment in SCL language?

As you saw earlier, a comment is a part of SCL language which is used to describe what is the use of the statement that you are writing. Similar to how we write comments in ladder language or any other language for describing what is the meaning of the logic that you are writing, a comment is used similarly in the SCL language for the same purpose. Comments do not affect the execution of the logic written inside the statement. Yes, but it depends on what you’re commenting and why you are commenting.

Also, if you do not require logic to execute, then you can use a comment to bypass that statement. The PLC scan time will not execute that comment or statement. The PLC scan time will not execute that statement during runtime.

Let us see below some general types of comments used in a program:

  1. On a single line –

 (* statement *) or // statement

  1. More than one line –

(*

Statement-1

Statement-2

*)

As you can see, // syntax is used when you are commenting on only a single line. But, (*…*) syntax is used for all the types of lines, whether single line or multiple lines. This syntax is thus very powerful in executing. In the later part, we will see examples on how to write comments.

How to write comments in SCL language?

Let us understand three examples on how to write comments in SCL language.

  1. In the first one, we will describe the use of the logic written. For that, suppose we write the line as shown in the image below, we see that we are describing one whole construct with a single line. It gives an overall description of the logic written. We write it as a – // while-do statement. It is simply describing or naming our logic. This helps in easier troubleshooting for the programmers in a longer run.
Use of Comments in SCL Language
  1. In the second one, we will bypass this whole construct and not allow the PLC scan time to execute it. For that, suppose we write the line as shown in the image below, we see that we are bypassing one whole construct with two  lines. It gives an overall impression to the programmer that this logic is not in use currently. We write it as a – (* statement *). It is simply bypassing our logic. This helps in easier troubleshooting for the programmers in a longer run. You can easily identify commented parts by the green color shown. This is an added feature of PLC software.
What is a comment in PLC language
  1. In the third one, we will comment on the wrong line and see how it impacts our program. For that, suppose we write the line as shown in the image below, we see that we are bypassing a single line. But when we bypass that line, we see that the while keyword becomes red in color. It means that it did not find any end keyword for the construct. Due to this, the statement remains incomplete and the compile error will occur. So, do not just randomly comment on any line. You need to comment in such a way that it does not affect other logic too by bypassing it.
How to write comments in SCL language?

In the next post, we will see how to write regions in the SCL language.

Read Next:

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

Leave a Comment

Share via
Follow us and never miss an update!