Variables (For a Printable Version Click Here) A note on using variables:You can create new state variables for turtles, patches, and the observer. Whenever you create a new variable, StarLogo automatically creates a collection of new procedures to facilitate the use of the variable. For example, if you create the variableage for the turtles, then the turtles
can use the procedure setage to change the value of the variable,
and they can use the procedure age to access the value of the variable.
You create new variables with the commands turtles-own, patches-own, and globals. You can type these commands in either the turtle procedures window or the observer procedures window (but not both), like this:
For turtle variables, the example age is used. For patch variables, the example food is used. And, for global variables, the example time is used. In order to use the commands listed below, you must first create the variables you want. Here are a list of commands that affect variables. A popup box will open up if you click on the command name.
Local Variables Like Example: Parameters Parameters are like local variables, in that they only exist during the procedure they are associated with. They are "declared" when the caller of procedure gives them a value. Example: |