Vai al contenuto

Keywords and Scope

KeywordVariable usage
VARInternal to organization unit.
VAR_INPUTExternally supplied.
VAR_OUTPUTSupplied by organization unit to external entities.
VAR_IN_OUTSupplied by external entities, can be modified within organization unit.
VAR_EXTERNALSupplied by configuration via VAR_GLOBAL, can be modified within organization unit.
VAR_GLOBALGlobal variable declaration.
The scope (range of validity) of the declarations contained in structuring elements is local to the program organization unit (POU) in which the declaration part is contained. That is, the declared variables are not accessible to other POUs except by explicit argument passing via variables which have been declared as inputs or outputs of this unit. The one exception to this rule is the case of variables which have been declared to be global.Such variables are accessible to programs in any case, or via a VAR_EXTERNAL declaration to function blocks and functions. The type of a variable declared in a VAR_EXTERNAL must agree with the type declared in the VAR_GLOBAL block.To give access to this variables to all type of POU, without using any keyword, you must enable this option in the code generation tab of the project options (see Paragraph 4.6.2).There is an error if:
  • any program organization unit attempts to modify the value of a variable that has been declared with the CONSTANT qualifier;
  • a variable declared as VAR_GLOBAL CONSTANT in a configuration element or POU (the “containing element”) is used in a VAR_EXTERNAL declaration (without the CONSTANT qualifier) of any element contained within the containing element.