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. repeat 3 [forward 40 right 120] |
What happens if you want to draw a different size triangle? |
Making a Polygon Procedure. | |
The external angle of a polygon of n sides is 360/n edit "poly | |
Now add the code below. You can cut and paste to save time if you want.
to poly :length :sides | |
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. |