Declaration of temporary variables in ST
VAR_TEMP
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);
END_VAR
Meaning |
declaration of one or more internal →temporary variables, name_1 etc. must be →IEC-identifiers. 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).
Temporary variables and local variables (VAR ... END_VAR) are identical in functions and methods . logi.cals recommends for functions and methods to declare temporary variables within the section VAR ... END_VAR (instead within section VAR_TEMP ... END_VAR ,) . |
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_TEMP
temp1: BOOL;
temp2, temp3 : INT;
END_VAR
VAR_TEMP
temp4 : STRING[10];
temp5: ARRAY [1..2] of BOOL;
temp6 : INT;
myRefTemp1: REF_TO INT;
END_VAR