Editing, Saving, Procedures & Loading.

Logo is a structured programming language. This means that you can save time and make powerful programs by writing what are known as procedures.
A procedure is a set of instructions which are then stored by the computer and can be called over and over again without having to retype the code.

repeat 3 [forward 40 right 120]

What happens if you want to draw a different size triangle?
Could you adapt this program to draw any polygon?

Making a Polygon Procedure.

The external angle of a polygon of n sides is 360/n
You can write a general polygon procedure as follows:
First type edit "poly in the command line window.

edit "poly

Now add the code below. You can cut and paste to save time if you want.

to poly :length :sides
repeat :sides [fd :length rt 360/:sides]
end

Now click on the "file" menu and select "save and exit".

Now enter the command

poly 60 6

This draws a hexagon with sides that are 60 pixels long.

You can hide the turtle by typing ht. This stops it appearing in your designs.

HOW TO SAVE YOUR WORK TO DISC!!

Having gone to the trouble of writing a procedure or two, you should now save it to disc so that you can use it over and over again.

Use the file menu in the main program window. Then select save as just as you would in Word or Excel.

HOW TO LOAD YOUR WORK FROM DISC!!

If you double click on your file Logo may well load but it won't load your program. To do this you need to use the file and load menu.

Use the file menu in the main program window. Then select load just as you would in Word or Excel.

You can test to see if your procedure is there by typing:

poly 80 8

An alternative is to type pots in the command line. This lists all the procedures present along with the names of the arguments that must be passed to them.

pots

This tells you that you have a procedure called poly which requires two arguments (numbers) :length and :sides passing to it.

Another useful trick, especially for long programs, is to open your program with Notepad. This enables you to see all your program at once.
You can then use the edit & replace menus to make a lot of changes quickly.
This is also the easiest way to paste big chunks of old procedures into new programs.
Remember to use the save as all files option and add the extension .lgo

Last updated April 8th 2008