Variable Declaration Keywords (Usage)
The keywords listed below define the scope of variables. The can be selected in the 'Usage' column of local variables tables or Data Lists. Which keywords are available depends on the table, that is to say, the POU type where the variable is declared. Refer to the topic "Variable Properties" for details.
This topic contains the following sections:
Declarations in local variables tables
Keyword | Declaration | Used in | ||
---|---|---|---|---|
Local | Declaration of local variables and function block instances.Related IEC 61131-3 declaration keyword: VAR | Variables table, all POU types | ||
Input | Declaration of variables which serve as input formal parameters of functions, function blocks, and methods. By means of an 'Input' variable, a POU can receive a value. Within the POU
or method, the input variable can only be read but not written.Related IEC 61131-3 declaration keyword: VAR_INPUT
| Variables table of function and function block POUs | ||
Output | Declaration of variables which serve as output formal parameters of function blocks. By means of an 'Output' variable, POUs can pass a value to other POUs. Within the POU, an 'Output' variable can be read and written.Related IEC 61131-3 declaration keyword: VAR_OUTPUT
| Variables table of function block POUs | ||
InOut | Declaration of variables which are both, input and output formal parameters of FBs. Typically, this is done for complex data types such as strings, arrays and structures. The address of an input/output variable is passed by reference. Within the POU, the variable can be read or written.Related IEC 61131-3 declaration keyword: VAR_IN_OUT
| Variables table of standard function block POUs.
|
||
External | Local declaration of a global variable in the POU where it is used (see description of 'Global' keyword). The value of an 'External' variable is supplemented by the related 'Global' declaration. This value can be modified by the POU. | Variables table, all POU types | ||
Instance | Declaration of a local variable which is going to be used as an instance-related variable. After selecting the 'Instance' keyword, the field 'I/Q' for selecting a data direction is enabled. Refer to the topic "Instance-related Located Variables " for further information. | Variables table of program and function block POUs
|
||
Program | Declaration of a program-global variable.While resource-global variables can be used in all POUs under the current resource (acc. to IEC 61131-3), program-global variables can be used in the program where they are declared as well as in all FBs which are instantiated in this program POU. For that purpose, the variable must be declared in the respective FB as external variable (similar to a resource-global variable). Program-global variables can also be used as instance-related I/O variables. Refer to the topic "Instance-related Located Variables" for further information. | Variables table of standard program POUs.
|
||
IN PortOUT Port | Declaration of an IN port or OUT port in a program POU when working with a PLCnext Technology controller. By means of an IN port, the POU can receive a value from an OUT port of another program. Via an OUT port, the program can pass a value to an IN port of other POUs.
![]()
| Variables table of program POUs when working with a PLCnext Technology controller |
Declarations in Data Lists
Keyword | Declaration | Used in | |
---|---|---|---|
Global | Declaration of global variables which can be used in all POUs executed by the respective controller (resource). Safety-related and standard (non-safety-related) code is strictly distinguished in PLCnext Engineer. Both the standard controller and the Safety PLC have their own, separate Data List with 'Global' declarations. A controller-global variable cannot be used in the Safety PLC and vice versa.For the standard controller, global variables can be declared as retentive variables (using the 'Retain' property). The Safety PLC does not support retain variables.
| Data List of the controller and the Safety PLC | |
Instance | Declaration of an instance-related local I/O variable. Such declarations have been inserted automatically for each instance of local variables that have been declared using the 'Instance' keyword in a local variables grid of a program or FB POU. See topic "Instance-related Located Variables" for further information. | Data List of the controller
|
|
Program | Declaration of an instance-related program-global I/O variable.Such declarations have been inserted automatically for each instance of program-global variables that have been declared using the 'Program' keyword in a local variables grid of a program POU. See topic "Instance-related Located Variables" for further information. | Data List of the controller
|