Chapter 4 Programming with Scratch^67
THE OFFICIAL RASPBERRY PI BEGINNER’S GUIDE
This is because the repeat until block is working in exactly the same way as the
repeat 10 block, but rather than counting the number of loops itself, it’s comparing the value
of the ‘loops’ variable to the value you typed to the right of the block. When the ‘loops’ variable
reaches 10, the program stops.
5 Figure 4-8: Using a ‘repeat until’ block with a comparitive operator
This is known as a comparative operator: it literally compares two values. Click on the
Operators category of the blocks palette, and find the two other diamond-shape blocks above
and below the one with the ‘=’ symbol. These are also comparative operators: ‘<’ compares two
values and is triggered when the value of the left is smaller than the one on the right, and ‘>’
triggers when the value on the left is bigger than the one on the right.
Click on the Control category of the blocks palette, find the if then block, then click and
drag it to the scripts area before dropping it directly beneath the say loops for 2 secs block.
It will automatically surround the change loops by 1 block, so click and drag on that to move
it so it connects to the bottom of your if then block instead. Click on the Looks category
of the blocks palette, then click and drag a say Hello! for 2 secs block to drop it inside your
if then block. Click on the Operators category of the blocks palette, then click and drag the
n > n block into the diamond-shape hole in your if then block.