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] :=
'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. *)
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 or JSON string for variables and data types " for details.
VAR_EXTERNAL
portSetting : INT;
upTime : TIME;
gVar1: ARRAY [1..2] of BOOL;
gVar2: STRING[10];
END_VAR
VAR_EXTERNAL
VALVE_POS : INT;
END_VAR