Initialising of structures

Question:

How can a structure or a structure field be initialised, this means values are already pre-selected, before the SPS program is activated?

Answer:

In the variable declaration editor of a program, in which the type of a variable is declared, a variable's value can be pre-selected. If a structure is to be set as a field in the data type field, the variable declaration editor must have the following format.

Structure, which is declared in the data type field
TYPE data :
STRUCT
  wVar1:WORD;
  wVar2:WORD;
END_STRUCT
END_TYPE

Entry in the variable declaration editor

PROGRAM Container1
VAR
sttVarTest:ARRAY[0..1] OF  Data :=  ( wVar1:=3, wVar2:=3),( wVar1:=3, wVar2:=3);
END_VAR

URL for linking this AKB article: https://www.lenze.com/en-de/go/akb/20022792/1/
Contact form