1

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)])

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.