The content below is copied from the ACR-View Help File( see Declaration Editor):
Variables are declared in different sections called declaration blocks. A declaration block starts with a keyword and ends with END_VAR (for example: VAR_GLOBAL . . . . . . END_VAR).
According to the POU-type only certain variable-sections can be used:
- A POU of type Program may use Type, Local, Global and External
- A POU of type Function block may contain Type, Input, Output, In_Out, Local and External
- A POU of type Function may use Type, Input and Local.
VAR_INPUT: If a variable block should only be read inside a POU, you must declare this variable as input variable. It thereby is not allowed to modify this variable in this POU. An input variable can be used for the parameter transfer in a function or function block.
VAR_IN_OUT: An input/output variable is accessed under the same name by a function block. The variable gets a reference (pointer) to the transferred variable and its memory location during the parameter transfer by the block call. Because a write operation has a direct effect to the content of an In_Out variable, it isn't allowed to use a write-protected type for the transferred variable as INPUT variables or variables with attribute CONSTANT
VAR_OUTPUT: The Output-variables are declared in the function block that uses them for the return of values. The calling POU can access them.
VAR_GLOBAL: A variable should be declared as global variable in the POU "program" if this variable should be valid in this POU and in the function blocks called by this POU. This variable must be declared as external variable (VAR_EXTERNAL) in all function blocks which intend to use this variable.
Note - for variables that will be used routinely in every resource in the project, the variable can be declared as VAR_GLOBAL in a .POE file as part of the project. However, the .POE contents are scanned before each individual project resource so too many globals declared here can affect the overall scan time performance. When declared as a VAR_GLOBAL inside of a POU, they are only scanned when that particular POU is run.
VAR_EXTERNAL: If a declared global variable will be used inside a function block, this variable must be declared as external variable inside this function block.
VAR: A local variable is only valid inside the POU in which it was declared. The declaration of local variables can be supplemented by the attributes "RETAIN" or "CONSTANT", or by an address.
TYPE: The keyword TYPE is used for declaration of user defined (derived) data types with local scope in the POU types "program" and "function block", or with global scope in the type definitions.