|
Lesson 6: Loops |
|
©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]
And we will continue to improve LOGO programming. Are you already tired of typing the same thing again and again ? So you will be interested in the command repeat (or re). You use it exactly like the command goto, except that you tell LOGO how often he is supposed to repeat the procedure. The procedure square will look as follows:
The procedure main just tells LOGO to draw the square. In the procedure square you will find the essential command repeat drawing four times the procedure go_and_right which only draws one side of the square and turns 90 degrees, thus setting LOGO in the right position for the next side. Look at it again in step-by-step view and you'll see how this produces a square. Now you can try to draw another village using your procedure house and the command repeat. If anything doesn't work as you wanted it to, make sure that after each house LOGO is in the right position and looks in the right direction to draw the next one. Using the example of the procedure square that we gave you, try to change the value of the angle to 120, 72, 60, 45 or 30 and to find out the number of repetitions needed by LOGO to regain the point where he started. You may also change the value behind go and see what it changes. |