Skip to main content

Global Variables

Global variables are declared in a specific file (Text) and can be accessed by any part of the program. Their declaration must begin with the VAR_GLOBAL keyword and end with END_VAR.

Retainable global variables can also be declared using the RETAIN keyword, so that their values are preserved even after the device is restarted. Furthermore, global constants can be defined using the CONSTANT keyword, which represent fixed and unchangeable values during program execution.

Local Variables

Local variables are declared in the same code block where they are used. Their declaration must be grouped, beginning with the VAR keyword and ending with END_VAR.

These variables are accessible only within the scope in which they were declared, meaning they cannot be used by other parts of the program. This ensures greater control over memory usage and avoids conflicts between different code snippets.

Note: ¹ There is no distinction between uppercase and lowercase letters in variables.