Keyword Reference


ContinueLoop

Continue a While/Do/For loop.

ContinueLoop [level]

Parameters

level [optional] The level of the loop to restart. The default is 1 (meaning the current loop).

Remarks

ContinueLoop will continue execution of the loop at the expression testing statement (that is the While, Until or Next statement).

A negative level or zero value has no effect.

Even though any program that uses ContinueLoop can be rewritten using If-ElseIf-EndIf statements, ContinueLoop can make long scripts easier to understand.
Be careful with While/Do loops; you can create infinite loops by using ContinueLoop incorrectly.

Related

Do, ExitLoop, For, While

Example

Example 1

#include <MsgBoxConstants.au3>

_Example()
Func _Example()
        ; Display all the numbers for 1 to 10 but skip displaying  7.
        For $i = 1 To 10
                If $i = 7 Then
                        ContinueLoop ; Skip displaying the message box when $i is equal to 7.
                EndIf
                MsgBox($MB_SYSTEMMODAL, "", "The value of $i is: " & $i)
        Next
EndFunc   ;==>_Example

Example 2

#include <MsgBoxConstants.au3>

_Example()
Func _Example()
        For $o = 1 To 3 ; "outer loop"
                For $i = 1 To 10 ; "inner loop"
                        If $i = 1 Then ConsoleWrite(@CRLF)

                        If $o = 1 And $i = 3 Then ContinueLoop 2 ; if "outer loop" is in first step and "inner loop" is in 3 step, skip "outer loop" to next step
                        If $o = 2 And $i = 5 Then ContinueLoop 2 ; if "outer loop" is in second step and "inner loop" is in 5 step, skip "outer loop" to next step
                        If $i = 7 Then ContinueLoop ; if "inner loop" is in 7 step, skip "inner loop" to next step
                        ConsoleWrite(" The value of $o=" & $o & "  $i=" & $i & @CRLF)
                Next
        Next
EndFunc   ;==>_Example