g.mccormick
Lifetime Supporting Member
In structured text, can you decrement in a for loop?
I need to shift an array and I can either use while loop or if decrement in for loop works id do that.
Will this work?
VAR
index: INT;
my_arr: ARRAY[1..12] OF REAL;
END_VAR;
FOR index := 12 TO 2 BY -1 DO
my_arr[index] := my_arr[index-1];
END_FOR;
I need to shift an array and I can either use while loop or if decrement in for loop works id do that.
Will this work?
VAR
index: INT;
my_arr: ARRAY[1..12] OF REAL;
END_VAR;
FOR index := 12 TO 2 BY -1 DO
my_arr[index] := my_arr[index-1];
END_FOR;