|
Lesson 4: Procedures |
|
©1997/1998 Sebastian Golze, Thomas Hirsch
und
|
[1_First_steps] [2_Turn_left_turn_rigth] [3_With_colors] [4_Procedures] [5_Parameters] [6_Loops] [7_More_parameters] [8_Stars] [9_Upload_and_Download] [10_LOGO_learns_to_write]
As you know from the introduction, everything in LOGO is built of procedures. And there's not only the procedure main: A procedure simply declares a thing which can be drawn by LOGO. You may name the examples in the last lessons procedure square or procedure house as well. Thus, you did not only rename a program, but taught a new word to LOGO. If this procedure is located anywhere in your program (except inside another procedure), you only have to tell LOGO to draw a square or a house, instead of repeating the single steps. This is the same as when you learned to write: At the beginning, you've been told that an "A" consists of two diagonal lines crossed by a third horizontal one. Today, you're only told, "write an 'A'" or even "write 'Alabama'", and you will know what is meant. If you want to tell LOGO to draw a learnt figure, type goto square and he will understand you. A program that uses different procedures can be found in the programming window... If you look at the program step-by-step, you'll see that LOGO, as soon as he reads the command goto , goes to the respective procedure and executes its commands. Or can you draw an A otherwise than with three lines ? You only have to remember that all the procedures have to be in the same program as the respective command goto As long as you do not tell LOGO to memorize a procedure - we will show you how to do this later - he will forget it until your next session. Turtles don't have the memory of an elephant... Now draw a whole village by repeating the procedure house over and over again.
After that, you should try to write your own procedure - a triangle maybe. |