0

Drop out of a FOR loop early

Is there a BREAK command word to stop a loop -  when a condition is met prior to cycling thru all the items in the loop?  Can't seem to find a way to make it work without using a WHILE loop instead.

3 replies

null
    • Sean
    • 5 yrs ago
    • Reported - view

    Once the condition is met, set your loop variable to a value greater than your maximum loop value.

    • glenn
    • 3 yrs ago
    • Reported - view

    The only way I figured out how to do this is to have use the else statement.

    If x=1 then do......

    else 

    do......

    • Sean
    • 3 yrs ago
    • Reported - view

    Yeah, it my solution only works for this style...

     

    Screen Shot 2020-07-11 at 7.32.28 AM

     

    let count := 0;
    for i from 0 to 10 do
    count := count + 1;
    i := 20
    end;
    count

Content aside

  • 3 yrs agoLast active
  • 3Replies
  • 1820Views