How can you pass an array of structure as an argument to a function block?
Initializing the array dirrectly as an argument didn't work:
myFunctionBlock(inArrayOfStruct := [(Param1 := TRUE), (Param1 := FALSE)])
How can you pass an array of structure as an argument to a function block?
Initializing the array dirrectly as an argument didn't work:
myFunctionBlock(inArrayOfStruct := [(Param1 := TRUE), (Param1 := FALSE)])
I think the error message if you try this:
fb: FB(inArrayOfStruct := [(Param1 := TRUE), (Param1 := FALSE)]);
says it all:
[ERROR] C0304: An array initialisation is not possible as parameter of an initial function call. Use a variable instead
Just use a variable:
arr: ARRAY [0..1] OF DUT := [(Param1 := TRUE), (Param1 := FALSE)];
fb: FB(inArrayOfStruct := arr);
or
arr[0].Param1 := TRUE;
arr[1].Param1 := FALSE;
fb(inArrayOfStruct := arr);