Declaration of output variables in ST

Syntax
VAR_OUTPUT (* optional_begin *) RETAIN NON_RETAIN (* optional_end *)
name_1, name_2, ..., name_n : data-type := initial-value;
name_3, name_4, ..., name_n : STRING[length] := 'initial-value';
name_5, name_6, ..., name_n : ARRAY [x..y] OF type := [initial-value_1, initial-value_2, .., initial-value_n];
name_7, name_8, ..., name_n : ARRAY [x1..y1, x2..y2, x3..y3] OF data-type; (* Here, initial values are possible as well. *)
name_9, name_10, ..., name_n : REF_TO type := REF(name_A);
FB_instance_1, FB_instance_2, ..., FB_instance_n : FB-type := ( input_1 := initial-value, input_2 := initial-value, ..., output_n := initial-value);
END_VAR

Meaning

Declaration of one or more →output variables, name_1, name_2 etc. must be →IEC-identifiers.
The declaration of more sections of this kind is allowed. The declaration is possible within declaration of a →program, of a →function block, of a →function or of a →method.

Providing the optional keyword RETAIN or NON_RETAIN makes all elements of this section →retentive or non-retentive. RETAIN or NON_RETAIN is possible within the declaration of a program and the declaration of a function block . If variables are declared based on a structured data type within the section with RETAIN or NON_RETAIN, its structure elements (incl. nestings) are treated as retentive or non-retentive alike.

A →data type is possible as type for a variable.

See "Supported data types" to learn which data types are supported for the declaration of variables. Use the optional →initial value [:= initial-value] to assign a value to the variable (see "Initialization of variables in ST" for details).
Moreover, it is possible to declare:

The declaration of output ENO is not necessary. See "Execution control: EN, ENO" for information on output ENO

Good to know

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg Moreover, logi.CAD 3 allows you to specify additional data for the declaration . See " Defining description, comment or JSON string for variables and data types " for details.

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg Within a section VAR_OUTPUT...END_VAR, it is also possible to declare function block instances and to declare variables based on an interface.

Example
VAR_OUTPUT
OUT : BOOL;
ET_OFF: TIME;
O1: ARRAY [1..2] of BOOL;
O2 : STRING[10];
myRefO: REF_TO INT;
END_VAR