Talking to yourself
Page 9
If you want to keep a secret from the turtle you can write a semicolon. Like this:
Anything after a semicolon is called a "comment". That means the turtle won't hear it.
Why would you want to tell the turtle something that he doesn't hear? What's the point of that? Here's an example. Look at the following Logo code:
SETPC 4
REPEAT 4 [FD 50 RT 90]
PU
LT 180
FD 100
PD
SETPC 2
REPEAT 3 [FD 50 RT 120]
If you want to understand it you can Think Turtle. But it's a lot of work to Think Turtle all the time. Maybe this is easier:
CS
; then draw a red square
SETPC 4
REPEAT 4 [FD 50 RT 90]
; then move the turtle to below the square
PU
LT 180
FD 100
; now put down the pen again
PD
; and draw a green triangle
SETPC 2
REPEAT 3 [FD 50 RT 120]
That's what comments are for. With comments you only have to Think Turtle once. They make it easy for you to understand your own code. But they have to be secret to the turtle. Remember that the turtle only understands his own turtle language. He doesn't know what to do when you speak to him in your own language.
Of course, comments are only useful if you write in the editor. Like when you give things names.
It's a good idea to always write comments in your code. Otherwise your head hurts when you look at it. Mine does too. I always write comments. All programmers do. (People who write code, like you and me, are called "programmers".)
These are the words we know now:
| 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 |
| ; | Don't listen to me now |
A comment isn't really a Logo word. But that's ok. It can be in the list anyway.
These are the words we have taught the turtle. They are the same as on the last page:
| New Logo word | What it means |
|---|---|
| SQUARE | Draw a square |
| CIRCLE | Draw a circle |
| STAR | Draw a star |
Turn page, or back to the table of contents.