When we use procedure squareanysize :side must have a value. Hence an instruction squareanysize 150 would produce a square with sides of 150 units. Try adding two procedures together and see what happens. For example, from an instruction.

cs squareanysize 100 rt 45 squareanysize 150

the turtle will draw two squares of differing size sides and one will be at a 45 degrees angle to the other.

Notice how Dr. Logo reminds you that a line of commands has split across more than one line of screen.

4.7 Using Variables to remember values.

Dr. Logo will also allow us to use variables to remember values as well as for passing values to a procedure. First define a new procedure called triangle:

to triangle

repeat 3 [fd :edge rt 120] end

We can test this by typing:

make "edge 100 triangle

If we want to know the value remembered by edge we can just type edge after the ? prompt and Dr. Logo will print the value.

Finally we can use our variable :edge in a new procedure to draw a pattern. Notice how the value of :edge is increased by adding to its previous value so that each time we draw the pattern it gets bigger.

to pattern

triangle lt 60 triangle rt 60 make "edge :edge+ 4 pattern

end

make "edge 10 cs pattern

When you have seen enough, press [ESC] to stop the program.

4.8 Editing programs and procedures

Dr. Logo allows us to correct typing mistakes and to alter procedures that we have defined. The editing keys to use are:

The cursor Keys [][][][] which move the cursor by one character or line at a time.

The cursor Keys [][][][] pressed at the same time as holding down [CTRL] will move the cursor up and down a page and to the left and right of a line.

AMSTRAD Disc Drive & Interface DDI-1 Manual

Chapter 4.4

Page 62
Image 62
Amstrad DDI-1 Using Variables to remember values, Editing programs and procedures, To triangle Repeat 3 fd edge rt 120 end