ScriptTap
Break Loop

Command video guide

Break Loop

Break Loop exits the nearest enclosing Loop immediately. Execution continues after its matching End Loop; it does not stop the whole script.

This guide creates a separate copy of the Loop guide example, preserving the original. A loop set for three passes runs its Repeat prompt once, then Break Loop sends execution to the Complete prompt after the block.

  • Place Break Loop inside a Loop, before its matching End Loop.
  • It skips the remaining commands in that loop and all remaining repeats.
  • With nested loops, only the nearest enclosing Loop is exited.
  • There are no additional command settings. Put Break Loop inside an IF block when a condition should end the repetition.

Watch the walkthrough

Step-by-step guide

  1. Step 01

    Break Loop exits the nearest active Loop early. The script continues after its matching End Loop instead of stopping completely. In this example, a loop is set for three passes, but we will leave it after the first.

    Break Loop step 1: Break Loop exits the nearest active Loop early. The script continues after its matching End Loop instead of stopping completely. In this example, a loop is set for three passes, but we will leave it after the first.
  2. Step 02

    We will reuse the setup from the Loop guide. Open Scripts, find the Loop example, and choose Duplicate from its menu. This creates a new copy and leaves the original unchanged.

    Break Loop step 2: We will reuse the setup from the Loop guide. Open Scripts, find the Loop example, and choose Duplicate from its menu. This creates a new copy and leaves the original unchanged.
  3. Step 03

    Open the copy's menu and choose Rename. Give the new script a name, then tap OK and select it.

    Break Loop step 3: Open the copy's menu and choose Rename. Give the new script a name, then tap OK and select it.
  4. Step 04

    Open the Script Editor and collapse the extra overlay controls.

    Break Loop step 4: Open the Script Editor and collapse the extra overlay controls.
  5. Step 05

    This loop is set for three passes with Concurrent off. The Repeat prompt is inside the block. The Complete prompt is after End Loop, so it confirms that execution has left the loop.

    Break Loop step 5: This loop is set for three passes with Concurrent off. The Repeat prompt is inside the block. The Complete prompt is after End Loop, so it confirms that execution has left the loop.
  6. Step 06

    Expand Logic. Break Loop becomes available when the script contains a Loop. It has no additional command settings.

    Break Loop step 6: Expand Logic. Break Loop becomes available when the script contains a Loop. It has no additional command settings.
  7. Step 07

    Drag Break Loop after the first PromptMe and before End Loop. Use the blue insertion line to place it inside the block.

    Break Loop step 7: Drag Break Loop after the first PromptMe and before End Loop. Use the blue insertion line to place it inside the block.
  8. Step 08

    When execution reaches Break Loop, it skips the rest of this loop and its remaining repeats. It affects only the nearest enclosing Loop. In a practical script, place it inside an IF block when a condition should end the repetition.

    Break Loop step 8: When execution reaches Break Loop, it skips the rest of this loop and its remaining repeats. It affects only the nearest enclosing Loop. In a practical script, place it inside an IF block when a condition should end the repetition.
  9. Step 09

    When the script is complete, simply use the Play button in the main overlay.

    Break Loop step 9: When the script is complete, simply use the Play button in the main overlay.
  10. Step 10

    Here is the first pass. The Repeat prompt waits for us to tap Next, then Break Loop will run.

    Break Loop step 10: Here is the first pass. The Repeat prompt waits for us to tap Next, then Break Loop will run.
  11. Step 11

    Tap Next. The Complete prompt appears now. The script has continued after End Loop without running a second or third pass.

    Break Loop step 11: Tap Next. The Complete prompt appears now. The script has continued after End Loop without running a second or third pass.
  12. Step 12

    Tap Done. The script finishes automatically. Use Break Loop to end a repetition early while allowing the commands after the loop to continue.

    Break Loop step 12: Tap Done. The script finishes automatically. Use Break Loop to end a repetition early while allowing the commands after the loop to continue.