Tips and Tricks: Variable list declaration

A typical variable declaration in TwinCAT goes like this:

VAR
    Variable : BOOL;
END_VAR

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

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

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.