-

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

KeywordDeclarationUsed in
LocalDeclaration of local variables and function block instances.

Related IEC 61131-3 declaration keyword: VAR
Variables table, all POU types
InputDeclaration 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

Note
Write access to input formal parameters of functions can be permitted by setting the compiler option 'Allow write on variables with usage input'. Select 'Extras > Options' and open the category 'Compiler | IEC Compiler Settings' and select the respective checkbox.

Note
When declaring formal parameter variables for a function or function block POU, the order of the declarations in the variables table determines the order of the appearance of the Fu/FB in the code (at the block symbol or in the ST parameter list). Using the 'Move up/down' icons in the toolbar of the variables table, you can change the order of the block formal parameters in the code.
/

Variables table of function and function block POUs
OutputDeclaration 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

Note
When declaring formal parameter variables for a function or function block POU, the order of the declarations in the variables table determines the order of the appearance of the Fu/FB in the code (at the block symbol or in the ST parameter list). Using the 'Move up/down' icons in the toolbar of the variables table, you can change the order of the block formal parameters in the code.
/

Variables table of function block POUs
InOutDeclaration 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

Further Info
Refer to the topic "InOut Variables: Rules and Specific Characteristics" for details on this variable type.

Variables table of standard function block POUs.

Note
InOut variables are not supported for safety-related POUs.

ExternalLocal 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
InstanceDeclaration 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

Note
Instance-related variables are not supported for safety-related POUs.

ProgramDeclaration 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.

Note
Program-global variables are not supported for safety-related POUs.

IN Port

OUT 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.

Background

Further Info
Further information can be found in the topic "PLCnext Technology controller generation".

Variables table of program POUs when working with a PLCnext Technology controller

Declarations in Data Lists

KeywordDeclarationUsed in
GlobalDeclaration 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.

Note
Global variables are declared as 'Global' in the Data List of the 'IEC 61131-3'/'Safety PLC' node and as 'External' in the local variables table of the POU where they are used.

Data List of the controller and the Safety PLC
InstanceDeclaration 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

Note
'Instance' is not supported for the Safety PLC.

ProgramDeclaration 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

Note
'Program' is not supported for the Safety PLC.