dabomb4097
Member
Hey all, I'm kind of new to structured text programming and I'm trying to understand why a routine someone else wrote doesn't quite work. There is a FOR statement nested inside an IF statement. The IF condition is a one shot, which only remains high for a single scan. Does an iterative FOR statement require more than one "scan" to run? Is it one scan per iteration or one scan for the entire FOR loop? The code block I'm having a problem with is something like this:
IF OneShot THEN
FOR x := 0 TO 24 DO
Count3[x] := Count2[x];
Count2[x] := Count1[x];
Count1[x] := 0;
END_FOR;
END_IF;
It only seems to perform the first copy on array element [0] and doesn't copy the rest of the array elements, so I think I have to hold OneShot on for multiple scans until the FOR Loop finishes? But I just wanted to check before I go changing a production program.
Thanks!
IF OneShot THEN
FOR x := 0 TO 24 DO
Count3[x] := Count2[x];
Count2[x] := Count1[x];
Count1[x] := 0;
END_FOR;
END_IF;
It only seems to perform the first copy on array element [0] and doesn't copy the rest of the array elements, so I think I have to hold OneShot on for multiple scans until the FOR Loop finishes? But I just wanted to check before I go changing a production program.
Thanks!