Image of LOGO LOGO

Lektion 5: Parameters

     English   Deutsch   Français
Your browser does not support Java for the moment. In order to use this page we strongle suggest that you go to the "Java Help" page. Please choose "Java_Help" in the small menu below. It's possible to use our page without Java but then you will have to download a Logo interpreter from our "Download" page.

[_Home_] [_Introduction_] [_Java_Help_] [_Download_] [_Learn_Logo_] [_Program_] [_Teacher_] [_Contest_] [_Discussion_] [_Procedures_] [_Perspective_] [_About_]

©1997/1998 Sebastian Golze, Thomas Hirsch und
Vinh Hoi Le Chau
. Please mail us if you had problems with our site os if you have any other suggestion.

Your browser does not support Java. Please read the text on the left side of this page about Java. If you work without Java you will have to use the HTML menu below this text.
[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]

Great. If you've made it to this lesson, you've already made your first steps to real programming. In fact, a good computer program does not only tell the computer what to do, but uses as much procedures as possible, to get a small size and a clear structure. If you had an almost infinite list of gos and rights, you would certainly not understand what LOGO is about to do. If you've got some well-named procedures, you'll see on the first view : "Hey - the procedure square draws a square !"

But what do you do, when you want to draw several squares of different size. For now, you're not able to tell LOGO "draw a large square", are you ?

You can draw a procedure respecting a certain value, a variable. A variable is a number that is able to vary. For example you want to vary the size of the squares that you draw. A procedure that can use any number for the size looks like this:

procedure square
go size
rt 90
go size
rt 90
go size
rt 90
go size
rt 90
end

If you compare this procedure to the former ones, you'll notice the word size. Right, that's a variable. But how do you tell LOGO to draw this square in a certain size ?
This command would look like that :

procedure main
goto square,size=100
end

Every time that LOGO encounters the name of the variable (size) in the procedure, he replaces it by the value after the equality sign (100).

Consider now, how to program a rectangle. You will need more than one variable, if you want to change both length and width. The command goto looks like the following

goto rectangle length=100,large=50

Separate all variables by commas. Thus you may use as much variables as you want. You can use your newly created procedure in another procedure house. Just place a triangle over that rectangle.
As you can see, you may call every procedure from every other procedure. But be careful not to call a procedure in another procedure that is itself called by the first one. LOGO would execute the commands in an eternal circle. In programmers words, you call that a circular reference

Please keep the procedure house for the next lesson...

lesson 4«------» lesson 6

Your browser does not support Java. With Java you would see here Logo sitting on his sheet of paper and the Logo interpreter. You have to activate Java or to use an external interpreter (which works exactly like this one) you can get at our "Download" section.