Templates are just normal functions with types as parameters. The following template function declares for-statements:
const proc: FOR_DECLS (in type: aType) is func
const proc: for (inout aType: variable) range (in aType: low) to (in aType: high) do
(in proc: statements) end for is func
variable := low;
if variable <= high then
while variable < high do
The body of the 'FOR_DECLS' function contains a declaration of the for-statement for the type aType.
Calling 'FOR_DECLS' with char and boolean
as parameter creates corresponding declarations of for-statements.
The example above is a simplified part of the library "forloop.s7i".