Notes about Procedures in StarLogo:

 

 

In the example shown above, I have created a procedure in the Observer.  The procedure is to ct and then to crt 1. 

Procedures have the word to followed by the name you want to call the procedure - in this case setup.

Procedures end with the word end.

In the command center I can then key in setup and the procedure will be executed.

The procedure was:

                 to setup

          ct

          crt 1

          end

 

Now I am going to make a procedure in the Turtle side.

 

The procedure that I am going to make is:

 

          to circle

          fd 10

          pd

          repeat 90 [fd 1 rt 4]

          pu

          end

 

 

Now I am going to execute this procedure.

 

Notice that when I told it to execute the procedure called circle, the circle was drawn.  The code before telling it to execute circle is to position the mouse where I wanted it. Note that when I change color, I can see the mouse

 

 

 

Now I am going to write the code to position the mouse where I want it and then I am going to execute circle again.  Well…  Anyway, you can see that if it cannot complete the circle it finishes by coming in from the top.  Now I am just going to execute the circle again - after changing color and see what happens?

 

Clearly I have given up doing anything but playing.  But hopefully you see that each time I type the word circle, the circle procedure is executed.  Can't resist adding one more…