Variables

Variables can be declared either locally in the declaration part of a POU or in a global variable list.

Note

In a project you can define a local variable which has the same name like a global variable. In this case within a POU the locally defined variable will be used. It is not allowed however to name two global variables identically. For example you will get a compiler error, if you have defined a variable “var1” in the PLC Configuration as well as in a global variables list.

The variable identifier may not contain any blank spaces or special characters, may not be declared more than once and cannot be the same as any of the keywords. Capitalization is not recognized which means that VAR1, Var1, and var1 are all the same variable. The underscore character is recognized in identifiers (e.g., “A_BCD” and “AB_CD” are considered two different identifiers). An identifier may not have more than one underscore character in a row. The length of the identifier, as well as the meaningful part of it, are unlimited.

Variables can be used anywhere the declared type allows for them.

You can access available variables through the Input Assistant.