-
One of the great things in computer programming
is once you've taught a computer how to do
-
an action, you can call that function again.
You give it a name and then you can call it.
-
That's really like extending the language.
In the program we built, we learned how to
-
draw a square by moving and turning four times.
We can take that function and give it a name,
-
draw a square so that any time we want to
do that, we simply say draw a square and it
-
will go back and invoke that function, that
code and it will get done for us. We've added
-
that concept to our programming language.
In this puzzle, we have already created a
-
draw a square function for you. You'll see
it in the toolbox as a green block. What you'll
-
need to do is write the same code you wrote
before to draw a square and put it in this
-
function. To do that, click on the edit option
in the green draw a square block. This will
-
open up the function editor. The function
editor has three parts. A place where you
-
name your function. This will appear on the
green block before that function. Then write
-
out a short description of what your function
is supposed to do. In this case, it's supposed
-
to draw a square. The white space below this
is the work space and works just like the
-
work space you've already been using. Drag
and drop blocks from the toolbox into this
-
work space. Remember to put the blocks that
create a square inside the green wrapping
-
block for the function. Once you're done,
click on save and exit. This will take you
-
back to the main puzzle work space. Now you
can use the draw the square function block
-
just like any other block to solve the puzzle.