For loops

Elric
2012-06-06
2012-06-11
  • Elric - 2012-06-06

    Hi all.

    Is there ANYTHING in CodeSys that allows you to force a for loop block to move to the next iteration? Like the "continue" command in most other languages? Is there an equivalent?

    Elric.

     
  • shooter - 2012-06-07

    If you put the var higher as the to value it will not enter the loop, (except when to value is 127 in SINT, then it will never end.)
    and you can check with IF statement. (in some cases RETURN works as it will leave a POU)

     
  • spfeif - 2012-06-11

    There if you want to leave a loop you can also use the EXIT command.

    FOR scounter := 0 to 100 DO
        IF (data[scounter] <> 255 THEN
            data[scounter] := data[scounter] + 1;
        ELSE
            EXIT;      (* This will terminate the for loop *)
        END_IF
    END_FOR
    
     

Log in to post a comment.