Declaration of external variables in ST
VAR_EXTERNAL (* optional_begin *) CONSTANT (* optional_end *)
name_1, name_2, ..., name_n : data-type;
name_3, name_4, ..., name_n : STRING[length];
name_5, name_6, ..., name_n : ARRAY [x..y] OF type;
name_7, name_8, ..., name_n : ARRAY [x1..y1, x2..y2, x3..y3] OF data-type;
(* Additional pieces of data are also possible
for
the variables. *)
(* Note: If a function block type is used as type
for
the variable, it is actually a function block instance. *)
END_VAR
Meaning |
declaration of one or more →external variables, name_1, name_2 etc. must be →IEC-identifiers. Providing the optional keyword CONSTANT prevents all external variables of this section from being overwritten during program execution (makes them →constants). The keyword CONSTANT is mandatory if the corresponding global variable has been declared CONSTANT.
|
Moreover, logi.CAD 3 allows you to specify additional data for the declaration . See " Defining description, comment, JSON string or type for variables or data types " for details.
If you prefer that logi.CAD 3 is creating the syntax for you: The application navigator provides the possibility to declare external variables and to have the declarations based on the already existing global variables. This is done when you drag the global variables from a global-object onto a →POU. Details: See "Declaring external variables by dragging and dropping global variables into POUs". In this case, you do not need to know the syntax described above.
Within a section VAR_EXTERNAL...END_VAR, it is also possible to declare function block instances.
VAR_EXTERNAL
portSetting : INT;
upTime : TIME;
gVar1: ARRAY [1..2] of BOOL;
gVar2: STRING[10];
END_VAR
VAR_EXTERNAL
VALVE_POS : INT;
END_VAR