Tips and Tricks: Variable list declaration

A typical variable declaration in TwinCAT goes like this:

    Variable : BOOL;

But did you know that TwinCAT also supports variable list declaration?

    Variable1, Variable2:BOOL;
    Variable3, Variable4, Variable5:INT;

A simple, but little known trick which might save you some space. I was however surprised to learn that the official TwinCAT documentation about declaring variables, doesn’t mention this feature at all..

Happy coding!


Gerhard Barteling

Gerhard is a mechatronic engineer with a predilection for software engineering.