0

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?

jibicax
  • 25
  • 5

1 Answers1

1

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;
Sergey Romanov
  • 2,949
  • 4
  • 23
  • 38