İAndrew M. Rudd http://business.virgin.net/sound.houses Books Poetry
MSW Logo is a completely free version of LOGO designed for use
with Microsoft
Windows. You can get it from the Internet from Softronix,
http://www.softronix.com/logo.html
Installing and setting up the program -
(Alternative instructions if you are using older versions of Windows )
Once you have downloaded the program just double-click SETUP.EXE (or go File -> Run -> C:\LOGO\SETUP.EXE) and follow the instructions on the screen.
Starting to use MSW LOGO
When you first run the program, a screen will appear with three areas:
The main area of the screen is where the Turtle (a
little triangle) moves around and
draws things.
At the bottom is a line (in the Commander box)
where you can type
commands.
When you press Return the turtle will obey your
instructions and the
commands will be listed in the grey area.
Commands
FORWARD 30 will make the turtle go forward 30 steps
(a step is about 1mm).
BACKWARD 30 will make the turtle go backward 30 steps
(a step is about 1mm).
RIGHT 90 will make the turtle turn through 90 degrees to the
right
LEFT 90 will make the turtle turn through 90 degrees to the left.
All these commands must be followed by numbers. They may be abbreviated:
FORWARD FD
BACKWARD BK
RIGHT RT
LEFT LT
PENUP lifts the turtles pen so that it does
not leave a trail.
PENDOWN puts the pen down again.
HOME sends the turtle back to the starting position, leaving a
line.
CS clears the screen and sends the turtle home.
REPEAT makes the turtle repeat an operation in square brackets
a
number of times. e.g.
REPEAT 4 [fd 50 rt 90]
will draw a square.
Procedures
These are programs or lists of instructions which you can
teach the turtle to perform.
To start a procedure which will draw a square, type:
EDIT SQUARE
and press Return. The Edit window will open
(the opening speech-mark tells Logo that this is a procedure
name. You can now type
the instructions)
TO SQUARE
REPEAT 4 [FD 60 RT 90]
END
END tells Logo that the procedure or program is finished. Go
to File, Save and exit.
You have added another word to the turtles limited
vocabulary!
Try it out. Type CS
(Return) then Square (Return). The turtle should draw a square.
You may edit the word again at any time by typing Edit Square and going back to the Editor screen.
Variables
Try this new word.
EDIT SQUARE2
TO SQUARE2 :SIDE
REPEAT 4 [FD :SIDE RT 90]
END
The colon is very important. It tells Logo that you are creating a variable, a word which stands for a variable number. To use this new procedure, type SQUARE2 then any number. The turtle should draw a square with the size of side you have chosen.
Heres a more complex program. Try it out, then see if you can work out how it operates.
EDIT POLYGON
TO POLYGON :SIDES
REPEAT :SIDES [FD 50 RT 360/:SIDES]
END
To try it out, type polygon followed by a number.
Now change the program a little:
EDIT POLYGON
TO POLYGON :SIDES :SIZE
REPEAT :SIDES [FD :SIZE RT 360/:SIDES]
END
Save and exit. Type POLYGON 5 100 and see what happens.
Colours
SETPC followed by a number sets the pen colour as
follows (these are just the first
few colours, there are many others
) You can also set the pen colour or
size from the menu bar.
0 black
1 blue
2 green
3 light blue
4 red
5 purple
6 yellow
7 white
8 dark red
9 brown
10 dark green
11 turquoise
12 orange
13 lilac
14 light orange
15 dark green
Recursion
Try this simple program.
EDIT BOX
to box :side
repeat 4 [fd :side rt 90]
box :side + 10
end
Type BOX 1 to start.
If you run this procedure the screen will fill with boxes until it is covered by a kind of graph paper. It will carry on until you click HALT to stop it.
This is what is happening. The first two lines are drawing a
square box with the side
you have set.
But before the program finishes, LOGO meets the
word BOX again, this
time with ten units added to the side. The word BOX
starts it all over again, so we
have an endless loop with the square getting bigger and bigger.
The process where a LOGO word calls or runs itself is called RECURSION. A recursive procedure is one which turns back on itself.
Putting in a condition
We probably would prefer this pattern to run a fixed number of
times rather than
going on for ever.
We can stop it by using a conditional
line. Edit the procedure,
putting in an extra line as follows:
EDIT BOX
to box :side
repeat 4 [fd :side rt 90]
if :side > 200 [stop]
box :side + 10
end
Can you see what happens? LOGO checks how big the side is every time the program loops. If the answer is greater than 200, then the program is stopped.
You can use this little program to make many satisfying patterns. Here is one to start with:
EDIT PATTERN
to pattern :angle
repeat round 360/:angle [box 50 lt :angle]
end
To run this you type Pattern followed by an angle. Round produces a whole round number (or integer) as Logo cant use fractions in deciding how many repeats to do. 360 divided by the angle gives the number of repeats to do. Try it with different angles.
EDIT PATTERN
to pattern :angle
repeat round 360/:angle [box 50 lt :angle]
end
And heres another version, even more elaborate Put in an angle and a colour number (e.g. 1)
EDIT PATTERN
to pattern :angle :colour
setpc :colour
if :colour = round 360/:angle + 1 [stop]
box 50
left :angle
pattern :angle :colour + 1
end
Back to Andrew Rudd's Web Site
Look at books by Andrew Rudd