Specifications

3 General Programming
3.10 SCL programming language: Tips and tricks
Programming Guideline for S7-1200/1500
V1.2, Entry ID: 81318674
67
Copyright
Siemens AG 2014 All rights reserved
3.10.6 FOR loop backwards
In SCL you can also increment the index of FOR loops backwards or in another
step width. For this, use the optional “BY” key word in the loop head.
Example
FOR #var := #upper TO #lower BY -2 DO
END_FOR;
If you are defining “BY” as “-2”, as in the example, the counter is lowered by 2 in
every iteration. If you omit “BY”, the default setting for “BY” is 1
3.10.7 Simple creating of instances for calls
If you prefer to work with the keyboard, there is a simple possibility to create
instances for blocks in SCL.
Example
Table 3-13: Easy creation of instances
Step Instruction
1. Give the block name a: followed by a "." (dot). The automatic compilation now
shows you the following.
2. On the top you can see the already existing instances. In addition, you can
directly create a new single instance or multi-instance.
Use the shortcuts "s" or "m" to go directly to the respective entries in the
automatic compilation window.
3.10.8 Handling of time tags
You can calculate the time tags in SCL just as with normal numbers i.e. you do not
need to look for additional functions, such as, e.g. T_COMBINE but you can use
simple arithmetic. This approach is called “overload of operands”. The SCL
compiler automatically uses the suitable functions. You can use a reasonable
arithmetic for the time types and can therefore program more efficiently.
Example
TimeDifference := TimeStamp_1 – TimeStamp_2;