User Guide

87
4.5 Loops
Loops have space in the middle for you to snap in other blocks,
and you can use them to run pieces of a script repeatedly. There
are three types of loop in Scratch: infinite loops, which run until
the script is stopped; definite loops, which run a set number of
times; and indefinite loops, which run repeatedly until a certain
condition is met.
The forever if and repeat until blocks seem very similar.
However, there are two important differences:
1. forever if runs blocks while the Boolean operation is
true – it ends when the operation is false. repeat
until runs blocks while the Boolean operation is
false – it ends when the operation is true.
Block Description
wait ? secs This is a special kind of loop that repeatedly does
nothing until the specified number of seconds has
elapsed.
forever Repeatedly runs the blocks until the script is
stopped.
repeat ? Repeatedly runs the blocks a set number times.
forever if ? Checks the Boolean operation and if it is true then
Scratch runs the blocks that are in the middle of
the loop. Then it checks the condition again. If the
Boolean operation is false, the looping ends.
wait until ? This is a special loop that repeatedly does nothing
until the Boolean operation is true.
repeat until ? Checks the Boolean operation. If it is false then
Scratch runs the blocks that are in the middle of
the loop. Then the loop checks the condition
again. If the Boolean operation is true, the
looping ends and Scratch runs the block below
the repeat until block.