Reputation: 25
I am trying to manipulate a sub-array of an existing array. Can Codesys do this? I guess this is more of a syntax question.
In Python, there is slice()
is there a Codesys equivalent?
Here's some pseudocode of what I am trying to do
VAR
Array1: ARRAY [1..3, 1..3] OF BOOL;
Statement: BOOL;
END_VAR
IF
Statement := TRUE
THEN
Array1[1,1..3] :=TRUE;
END_IF
[1,1..3] or [1,1:3] are not valid syntax. What is the appropriate way to access multiple cells?
Upvotes: 0
Views: 609
Reputation: 3080
You cannot set single value to a range of array elements. Syntax [1,1..3]
or [1,1:3]
will not work. You can only access one element at a time.
Array1[1,1] := TRUE;
Array1[1,2] := TRUE;
Array1[1,3] := TRUE;
Or
Array1[1,1] := Array1[1,2] := Array1[1,3] := Statement;
Upvotes: 1