I have the following code:
FUNCTION_BLOCK B VAR idA : INT; idB : INT; END_VAR METHOD FB_Init: BOOL VAR_INPUT bInitRetains: BOOL; // TRUE: the retain variables are initialized (reset warm / reset cold) bInCopyCode: BOOL; // TRUE: the instance will be copied to the copy code afterward (online change) idA : INT; idB : INT; END_VAR // B's FB_init: THIS^.idA := idA; THIS^.idB := idB; FUNCTION_BLOCK A VAR idA : INT; arrB : ARRAY[0..1] OF B[ (idA, 0), (idA, 1) ]; i : INT; END_VAR METHOD FB_Init: BOOL VAR_INPUT bInitRetains: BOOL; // TRUE: the retain variables are initialized (reset warm / reset cold) bInCopyCode: BOOL; // TRUE: the instance will be copied to the copy code afterward (online change) idA : INT; END_VAR // A's FB_init THIS^.idA := idA; PROGRAM PLC_PRG VAR arrA : ARRAY [0..1] OF A[ (0), (1), ]; i : INT; END_VAR
When running the program I would expect A[1].B[1] to have idA and idB to be 1. But idA is always 0.
How do solve this, without using an Init function that runs on the first cycle?
Log in to post a comment.
I have the following code:
When running the program I would expect A[1].B[1] to have idA and idB to be 1. But idA is always 0.
How do solve this, without using an Init function that runs on the first cycle?
Last edit: maoravni 2021-04-22