Creating Procedures in Scratch

Creating Procedures in
Scratch
Typing commands one after
the other using the green flag
only after all the commands
have been written would be
typical of Level 3 work in
Interactive Design.
Notice the first commands.
‘Clear’ clears the screen,
‘Point in direction’ sets the
Scratch cat to point right,
‘Go to x and y’ sets the
coordinates Scratch Cat starts
at.
More efficient commands are
shown in this example where
the repeat command is used
to replace move 50 steps turn
45 degrees being keyed in 8
times. These commands have
been placed inside a loop
which is told to do it 8 times.
This would be expected from
a pupil working with
procedures at Level 3.
A level 4 in Interactive Design should
show use of a procedure.
Break the repeat loop off the set (or
‘chunk’) of commands.
Drag the ‘broadcast’ command to the
main chunk of commands.
Click the downward arrow so that a
dialog box with ‘new’ appears and click
it.
A dialog box will appear.
Type in the name of the
procedure. In this example we
will call it ‘octagon’.
In the main set of
commands, the word
octagon now appears after
broadcast. When this is
broadcast, a procedure
called ‘octagon’ will occur.
Use the ‘when I receive’
command to call up the
commands that make an
octagon. Click the down
arrow and octagon will
appear. Click it to select.
A procedure has now been
created which draws an
octagon on screen.
In this example, octagon will
be broadcast in a repeat
command to make a
tessellating pattern.
This would be typical of a
pupil working well at Level 4
in Interactive Design.
Note the wait 0.3 secs. In
Scratch when repeating a
procedure it is necessary to
put a wait command in to
allow the procedure to be
completed before being
repeated.
Detach the repeat
block of commands
from the main
block. Add another
broadcast command
and create a new
procedure name. In
the example, we
will call this
‘tessellate’
Place a ‘when I receive’ command at the top of the repeat
block and use the ‘tessellate’ name. A procedure is now
nestled inside a procedure within Scratch as the procedure
called ‘tessellate’ now uses the ‘octagon’ procedure within
it.
This would be typical of a pupil working at Level 5 in
Interactive Design.