mathsnet.net subscribe to mathsnetgcse.com  

home geometry ASA2 curriculum puzzles articles books download about us try a short tour MathsNet.com

The A to Z of

The things you need to know about logo are summarised here, with particular reference to WinLogo, though note that much of what is written for WinLogo will apply to most other "Windows" logo programs as well.

- A -

Arithmetic

See Functions

- B -

- C -

Commands

See also Turtle commands

These are the common basic commands in Logo.

  • CS ClearScreen, clears the screen and resets the turtle back to its default position
  • CT clear the Text window
  • REPEAT repeats a set of instructions a number of times. The instructios are enclosed in square brackets. The common syntax for this is REPEAT 4 [FD 50 RT 90]
  • TO to begin writing a procedure
  • END denotes the end of a procedure
  • IF allows you to include conditional instructions. For example: IF RANDOM 2=1 [FD 30]. The if command must include a statement that is either true or false, and then a list when will be carried out if the statement is true. Two lists can be given, the first being carried out if the statement is true and the second if it isn't, for example: IF RANDOM 2=1 [LT 45] [RT 45]

Common errors

See Errors

- D -

- E -

Editing

Whenever you need to alter something you've typed in, this is called editing. Once words, numbers or any other instructions have been entered in the Work window, you can move back to them using the mouse to click where you need to be. You can use the Delete key or the backspace key (marked ) to remove numbers or letters. You can also scroll up and down the Work window using the scroll bar to its right to get to things you wrote a while ago. Remember that everything you type in is kept in the Work window until you delete it (by using clw "Work for example).

If you need to alter a procedure, then, after making your changes, you should move to the line that says simply End, click on this word and press Enter. This will register your edits with Win-Logo so that you can go on to use the edited procedure.

Errors

Here are listed the most common errors encountered when using logo.
Error Probable explanation
I do not understand... You have probably forgotten to put a space between words, eg, FD40 instead of FD 40
I do not know how to... You have not yet defined the procedure being used
I do know what to do with... You have probably used OUTPUT in a prodecure. Insert a PRINT command before it.

- F -

Functions

In logo you can use mathematical functions. Besides the four operators +, - / and *, you will usually find SUM, DIFFERENCE, PRODUCT AND DIVISION, together with SIN, COS, TAN and many others.

- G -

Geometry

Logo is sometimes refered to as "Turtle Geometry". The turtle exists in a 2D (or maybe 3D) world, with geometric attributes such as position and heading and it can be controlled so as to produce geometric shapes. Turtle geometry is to be viewed from the turtle's own viewpoint. For example, a procedure to draw an equilateral triangle is:

TO triangle
REPEAT 3 [FD 30 RT 120]
END

The angle involved is not the 60 degrees given by each internal angle of the triangle, but instead the 120 degrees through which the turtle has to turn in drawing the triangle.

- H -

Heading

See Turtle attributes

- I -

Information

You can get information about some aspects of your current Win-Logo work using the following primitives:

  • BACKGROUNDBG tells you the background colour
  • PENCOLOUR tells you the turtle's colour
  • HEADING tells you the direction the turtle is pointing
  • WHO tells you which turtles are active
  • POS tells you the turtle's position
  • XCOR tells you the turtle's x coordinate
  • YCOR tells you the turtle's y coordinate

Interpret

A procedure is created in logo by typing instructions like these:
TO SQUARE
REPEAT 4 [RT 90 FD 50]
END
The computer must then "learn" or interpret this prodecure in order that when you subsequently type in SQUARE it automatically draws the square. In WinLogo, once text has been typed into the Work window or loaded into the Work window using File... Load (Windows... Load in Dos version), it can be interpreted in two ways:

  1. Individual procedures. Move the cursor through the text in the Work window and press Enter on the word END at the end of each procedure required.
  2. All procedures. Select all the text in the Work window, by Edit... Select All Then interpret them all by selecting Area... Interpret. (In Dos version, click at beginning then select Edit... Block Start, click at end and select Edit... Interpret or press F10.)

- J -

- K -

- L -

Lists

Many versions of logo include "list-processing" procedures, ie., procedures that will work on a list of letters or words. WinLogo includes BUTLAST, BUTFIRST, FPUT, LPUT, FDIRST, LAST SENTENCE, LIST and others too. A detailed desciptions of lists is not included here, but as an example:
BUTFIRST [a b c d] will look at the list [a b c d] and return all of the list apart from the first item, ie., [b c d].

Loading

Loading files previously saved to disk can be achieved in two different ways. Suppose the file is called fred.log:

1. In the Work window. Type load "fred. This will load the contents of the file into memory and "interpret" them so that any procedures defined will be available for use. Use this method if you want to load files and run them immediately.

2. Using the Menus. Click on File... Load (Windows... Load in Dos version) and select fred.log from the list shown. This will load the file into the Work window. They have not been loaded into Win-Logo memory however, and so are not available at this moment to run. To load them into memory, your procedures need to be "interpreted". (See Interpret above for how to do this) Use this method if you want to load files and continue editing them.

Loops

See Recursion

- M -

- N -

Names

Variable names

In all versions of Logo, variables can be used when creating procedures. WinLogo uses the symbol : (colon) whenever referring to variable names. For example

TO SQUARE :side
REAPEAT 4 [FD :side RT 90]
END

The colon is used when introducing the name of a variable and when using the value of the variable.

Constant names

The primitive MAKE is used to give a constant a value, for example MAKE "size 20. Note the " symbol. When the value of the constant is used, the colon should appear instead:

FD :size

- O -

Operations

See Functions

Output

A common logo primitive is OUTPUT or OP, which is used to determine the result of a procedure, for example:

TO ADDUP :x :y
OP (:x + :y)
END

The result of applying ADDUP to two numbers is to add them up. However, if, having defined ADDUP, you enter ADDUP 5 6, you will not get 11 as logo's answer. Instead logo will say something like "I do not know what to do with 11". You have to tell logo what to do with that output, so something like this will work better:

TO ADDUP :x :y
PRINT OP (:x + :y)
END

- P -

Primitives

A primitive is a procedure provided in your version of logo, for example TO or FD or SETPOS.

Printing

To print the graphics, click in the Graphics window and then select File... Print. To print the procedures, click in the Work window and then select File... Print.

Procedures

See also Names and Interpreting

A procedure is a set of instructions beginning with TO and ending with END which logo can interpret and then carry out. Here is a simple procedure:

TO SHIFT
FD 10
END

Whenever SHIFT is entered, the turtle moves forward 10 steps.

- Q -

- R -

Recursion

In many programming languages it is possible to introduce "loops", that is, a way of making the program repeat endlessly - or a given number of times - a set of instructions. Logo is an excellent means of introducing the concept of a loop. Here is a simple example:

TO SQUARELOOP
RT 90
REPEAT 4 [FD 30 RT 90]
squareloop
END

This procedure will make the turtle turn right 90 degrees then draw a square, then turn 90 degrees and draw a square, and so on, and on, until the ESC key is pressed. The example shown is sometimes called "tail recursion", due to the loop being placed at the end of the procedure.

- S -

Saving

Saving files to disk can be achieved in two different ways. It is essential that you understand these differences. Suppose the file is to be saved as fred.log:

1. In the Work window. Type save "fred procedures. This will save all procedures (and only procedures) currently in memory into the file fred.log. Use this method if all you want to save are the procedures you've written and nothing else.

2. Using the Menus. Click on File... Save (Windows... Save in Dos version) and enter fred in the space next to Filename, overwriting *.log. This will save everything currently in the Work window - and nothing else! - in the file fred.log. Win-Logo will save an exact copy of the Work window contents.

Before you save your work, make sure you clearly understand what each method will achieve, and then choose the appropriate one.

- T -

Three dimensions

A few versions of logo have commands for controlling the turtle in three dimensions. The complete set of 3D WinLogo procedures is:
  • CLEAN3Drestores the axis system and sets the viewpoint at (0,0,600)
  • FORWARD3D move the turtle forward in three dimensions
  • POS3D tells you the coordinates of the current turtle
  • ROTATEX rotates the turtle about the x axis, similarly ROTATEY, ROTATEZ
  • ROTATEXAXIS rotates the axis system about the x axis, similarly ROTATEYAXIS, ROTATEZAXIS
  • SETPOS3D [ ] positions the turtle at the coordinates given
  • SETVIEWPOINT [ ] resets the viewpoint at the given x and y coordinates and the given distance in the z direction.
  • SETX positions the turtle at the x-coordinate given, similarly for SETY, SETZ
  • XCOR tells you the x-coordinate of the current turtle, similarly YCOR, ZCOR

Turtle attributes

See also Turtle commands

The turtle, the object that your logo instructions command, has two important attributes, its heading (ie., the direction it is pointing) and its position (as a pair of coordinates). Both of these are controllable, by using LT, RT, FD, BK or SETPOS.

The turtle may have other attributes too, like its colour, whether the pen is up or down (which determines whether or not the turtle will draw a line when it moves), its shape or its name.

Turtle commands

Most versions of Logo have the same set oif commands for controlling the turtle itself.
  • FD forward
  • BK back
  • LT left
  • RT right
  • HT hide the turtle
  • ST show the turtle
  • PU pen up. When the turtle moves it will not draw.
  • PD pen down. When the turtle moves it will draw.
  • SETPOS setpos [] positions the turtle at the co-ordinates given. A line is drawn.
Win-Logo uses a co-ordinate system with the origin in the centre of the screen and x axis from -320 to +320, y axis from -144 to +144. You can change just the x or y coordinate only by using:
  • SETX setx 50
  • SETY sety 60
  • SETHEADING sets the heading or bearing of the turtle, i.e., the direction the fd command will send it in.
Other commands particular to Win-Logo include

  • PENERASE After entering penerase, send the turtle back over an unwanted line, which will then be rubbed out. To switch off the eraser, type PD.
  • SETSHAPE setshape 6 will change the turtle's shape to that defined by the number given.

Multiple turtles

Many versions of logo allow more than one turtle on the screen simultaneously. WinLogo allows up to 12 turtles. They are numbered 1 to 12.
  • ACTIVATE selects which turtle you are currently commanding.
  • ACTIVATEALL selects all 12 turtles to carry out subsequent commands.
  • ASK temporarily selects a turtle or turtles to carry out a command, for example ASK 3 or
  • ASK [2 3 4]
  • EACH gives commands to each active turtle
  • WHO returns as a list the numbers of the active turtles

- U -

- V -

Variables

See Names

- W -

- X -

- Y -

- Z -


copyright mathsnet