Specifications

3 General Programming
3.10 SCL programming language: Tips and tricks
Programming Guideline for S7-1200/1500
V1.2, Entry ID: 81318674
66
Copyright
Siemens AG 2014 All rights reserved
3.10.4 Efficiently inserting CASE instruction
With the CASE instruction in SCL, it will be exactly jumped to the selected CASE
block condition. After executing the CASE block the instruction is finished. This
allows you, for example, to check frequently required value ranges more
specifically and easily.
Example
CASE #myVar OF
5:
FC5(#myParam);
10,12:
FC10(#myParam);
15:
FC15(#myParam);
0..20:
FCGlobal(#myParam);
// FCGlobal is never called for the values 5, 10, 12 or 15!
ELSE
END_CASE;
3.10.5 No manipulation of loop counters for FOR loop
FOR loops in SCL are pure counter loops, i.e. the number of iterations is fixed
when the loop is entered. In a FOR loop, the loop counter cannot be changed.
With the EXIT instruction a loop can be interrupted at any time.
Advantages
The compiler can optimize the program better, since it does not know the
number of iterations.
Example
FOR #var := #lower TO #upper DO
#var := #var + 1; // no effect, Compiler -> Warning
END_FOR;