ScriptTap
Loop

Command video guide

Loop

Repeat the commands between Loop and its matching End Loop without making copies of them. This guide explains the settings, then runs a prompt three times before showing a separate completion prompt.

  • Repeat: the total number of passes. The count is read when the loop starts and runs at least once, including when a value resolves to zero.
  • Delay: the wait in milliseconds before each repeat, not before the first pass or after the final pass.
  • Infinite Loop: repeat until the loop is exited or the script is stopped.
  • Concurrent: run the block in a separate branch while the parent continues after End Loop. The commands within that branch still run in order. Exclusive can temporarily hold other branches back.

Count and delay accept fixed non-negative Integers or Integer variables defined earlier, such as i1. The delay is read again before each repeat, so changing a delay variable can change the pacing. The demo uses count 3, delay 1000, Infinite Loop off and Concurrent off.

Watch the walkthrough

Step-by-step guide

  1. Step 01

    Loop repeats a group of commands without making copies of them. Place the actions between Loop and End Loop. In this example, a prompt will appear three times, followed by a separate completion prompt.

    Loop step 1: Loop repeats a group of commands without making copies of them. Place the actions between Loop and End Loop. In this example, a prompt will appear three times, followed by a separate completion prompt.
  2. Step 02

    Open Scripts. Tap New Script and choose Blank Script. We will build a separate example.

    Loop step 2: Open Scripts. Tap New Script and choose Blank Script. We will build a separate example.
  3. Step 03

    Open the new script's three-dot menu, choose Rename, and give it a name. Tap OK.

    Loop step 3: Open the new script's three-dot menu, choose Rename, and give it a name. Tap OK.
  4. Step 04

    Select the new script, open the Script Editor, and collapse the extra overlay controls.

    Loop step 4: Select the new script, open the Script Editor, and collapse the extra overlay controls.
  5. Step 05

    Expand Logic and drag Loop into the script. ScriptTap adds the matching End Loop automatically. Everything between these two boundaries belongs to the loop.

    Loop step 5: Expand Logic and drag Loop into the script. ScriptTap adds the matching End Loop automatically. Everything between these two boundaries belongs to the loop.
  6. Step 06

    Double-tap Loop to open its settings. The delay and repeat count control how the block runs.

    Loop step 6: Double-tap Loop to open its settings. The delay and repeat count control how the block runs.
  7. Step 07

    Delay is the wait between completed passes, measured in milliseconds. It does not delay the first pass. Enter one thousand for a one-second gap between repeats.

    Loop step 7: Delay is the wait between completed passes, measured in milliseconds. It does not delay the first pass. Enter one thousand for a one-second gap between repeats.
  8. Step 08

    Keep Infinite Loop off and set Repeat to three. This means three total passes, not one pass plus three more.

    Loop step 8: Keep Infinite Loop off and set Repeat to three. This means three total passes, not one pass plus three more.
  9. Step 09

    Either field can also use an Integer variable defined earlier, such as i1. The repeat count is read when the loop starts. The delay is read again before each repeat, so a changing variable can change the pacing.

    Loop step 9: Either field can also use an Integer variable defined earlier, such as i1. The repeat count is read when the loop starts. The delay is read again before each repeat, so a changing variable can change the pacing.
  10. Step 10

    Infinite Loop removes the fixed repeat count. The block keeps repeating until it is exited, for example with Break Loop, or the script is stopped.

    Loop step 10: Infinite Loop removes the fixed repeat count. The block keeps repeating until it is exited, for example with Break Loop, or the script is stopped.
  11. Step 11

    Switch Infinite Loop off again and enter three for this example.

    Loop step 11: Switch Infinite Loop off again and enter three for this example.
  12. Step 12

    Concurrent starts the loop as a separate branch. The parent script continues after End Loop while that branch runs. Commands inside the loop still run in order. Exclusive is the separate command for temporarily holding other branches back.

    Loop step 12: Concurrent starts the loop as a separate branch. The parent script continues after End Loop while that branch runs. Commands inside the loop still run in order. Exclusive is the separate command for temporarily holding other branches back.
  13. Step 13

    For our demonstration, turn Concurrent off. The script will finish all three passes before continuing after End Loop.

    Loop step 13: For our demonstration, turn Concurrent off. The script will finish all three passes before continuing after End Loop.
  14. Step 14

    Tap OK to save the loop settings.

    Loop step 14: Tap OK to save the loop settings.
  15. Step 15

    Collapse Logic, expand Advanced, and scroll to PromptMe.

    Loop step 15: Collapse Logic, expand Advanced, and scroll to PromptMe.
  16. Step 16

    Drag PromptMe into the script, then move its frame between Loop and End Loop.

    Loop step 16: Drag PromptMe into the script, then move its frame between Loop and End Loop.
  17. Step 17

    This prompt makes each pass visible instead of repeating an action with no obvious result.

    Loop step 17: This prompt makes each pass visible instead of repeating an action with no obvious result.
  18. Step 18

    Double-tap PromptMe. Keep Standard mode and enter Repeat as its header.

    Loop step 18: Double-tap PromptMe. Keep Standard mode and enter Repeat as its header.
  19. Step 19

    Keep Use Buttons on. Add one button named Next with Boolean output b1. Tap OK. The script will wait for us to acknowledge each pass.

    Loop step 19: Keep Use Buttons on. Add one button named Next with Boolean output b1. Tap OK. The script will wait for us to acknowledge each pass.
  20. Step 20

    Now drag a second PromptMe after End Loop. Because it is outside the block, this confirmation will appear only after the loop finishes.

    Loop step 20: Now drag a second PromptMe after End Loop. Because it is outside the block, this confirmation will appear only after the loop finishes.
  21. Step 21

    Double-tap this prompt and enter Complete as its header.

    Loop step 21: Double-tap this prompt and enter Complete as its header.
  22. Step 22

    Add a Done button with Boolean output b2. Tap OK to save the one-time confirmation.

    Loop step 22: Add a Done button with Boolean output b2. Tap OK to save the one-time confirmation.
  23. Step 23

    The first prompt is inside the loop and will run three times, with a one-second gap between passes. The second prompt is after End Loop and will run once. Keep the matching boundaries around only the actions you want repeated.

    Loop step 23: The first prompt is inside the loop and will run three times, with a one-second gap between passes. The second prompt is after End Loop and will run once. Keep the matching boundaries around only the actions you want repeated.
  24. Step 24

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

    Loop step 24: When the script is complete, simply use the Play button in the main overlay.
  25. Step 25

    Here is the first pass. PromptMe pauses this pass until we tap Next.

    Loop step 25: Here is the first pass. PromptMe pauses this pass until we tap Next.
  26. Step 26

    Tap Next. Loop waits one second, then starts the second pass and shows the same prompt again.

    Loop step 26: Tap Next. Loop waits one second, then starts the second pass and shows the same prompt again.
  27. Step 27

    Acknowledge the second pass. After the next one-second gap, the third pass begins.

    Loop step 27: Acknowledge the second pass. After the next one-second gap, the third pass begins.
  28. Step 28

    Acknowledge the third pass. The repeat count is satisfied, so execution continues after End Loop and the Complete prompt appears. There is no fourth pass.

    Loop step 28: Acknowledge the third pass. The repeat count is satisfied, so execution continues after End Loop and the Complete prompt appears. There is no fourth pass.
  29. Step 29

    Tap Done. The script finishes automatically. Use Loop whenever the same group of actions needs to run repeatedly without duplicating the commands.

    Loop step 29: Tap Done. The script finishes automatically. Use Loop whenever the same group of actions needs to run repeatedly without duplicating the commands.