Skip to content
Franco Montenegro edited this page May 25, 2016 · 3 revisions

Loops

While

while (someCondition)
    // ...
endwhile

Break

The break statement is just a translated version of exitwhen true.

Continue

local integer i = 0
loop
    set i = i + 1
    exitwhen i > 5

    if i == 3 then
        continue
    endif

    if i == 5 then
        continue
    endif

    call BJDebugMsg(I2S(i))
endloop

continue will ignore the iterations where i is equal to 3 and 5. Therefore, the message will be: 1, 2 and 4.

It also works in while loops.

Do keep in mind that this can lead to infinite loops if for example we move set i = i + 1 to the bottom (since i will eventually be 3 and we will skip the rest from there).

Clone this wiki locally