Naming things
Page 6If you want the turtle to draw a square you say:
You can't just say SQUARE. The turtle doesn't know what a square is. But you can teach him! First click the "Edall" button. A box pops up. That box is called the editor. Write TO SQUARE in the box. Then write the Logo code that makes a square. Then write END. Like this:
REPEAT 4 [FD 100 RT 90]
END
(You don't have to put spaces in front of the lines within the name. But it's easier to read that way.)
Then select "File" and "Save and Exit". That's it. Now you have taught the turtle what SQUARE means. Now you can just write SQUARE and the turtle will draw a square.
Try:
FD 50
SQUARE
You can CS and draw more squares. The turtle remembers.
Can you make the turtle draw two squares next to each other? Try!
Can you teach the turtle what TRIANGLE means? Try.
You can use names that you have taught the turtle inside other names. Maybe you have taught him WINDOW and DOOR. Then you can use those words when you teach him HOUSE.
Now you can teach the turtle what anything means. You can teach him what a house is. Or what a boat is. Or something else. You can also combine new words and REPEAT. Maybe like this:
See? Teaching the turtle new words makes everything easier!
These are the words we know so far. TO is new:
| Logo word | What it means |
|---|---|
| FD 100 | Walk forward 100 steps |
| BK 100 | Walk backward 100 steps |
| LT 90 | Turn left (good for drawing squares) |
| RT 90 | Turn right (good for drawing squares) |
| LT 120 | Turn left (good for drawing triangles) |
| RT 120 | Turn right (good for drawing triangles) |
| CS | Remove everything you have drawn |
| HOME | Move back to the starting point (and draw a line) |
| PU | Lift the pen so you won't draw when you walk |
| PD | Put the pen towards the screen again | REPEAT 10 [ ] | Repeat what's in the box 10 times |
| SETPC 4 | Change the pen to pen number 4 | TO ... END | Remember the word after TO in the future |
Turn page, or back to the table of contents.