Control Flow (Printable)
ask-list-of-turtles list-of-turtle-ids ilist [Observer,
Turtle]
Turtles whose who numbers (ID numbers) are in list-of-turtle-ids
run ilist. The caller of this command waits for it to finish before
continuing. If some invalid who numbers make up list-of-turtle-ids,
they are ignored.
ask-patches ilist [Observer]
This observer command asks all of the patches to run the ilist.
The observer will wait for the patches to finish before moving on.
ask-patch-at xcor ycor ilist [Observer, Turtle]
This command asks the patch which is xcor units in the x direction
and ycor units in the y direction away from the caller to run the
ilist. The caller of this command will wait for the patch to finish
before moving on. The observer is considered to be located at 0 0.
ask-turtle number ilist [Observer]
Asks turtle with ID number number to perform ilist.
The observer will wait for all of the turtles to finish before continuing.
ask-turtles ilist [Observer]
Asks all turtles to run ilist. The observer will wait for all
of the turtles to finish before continuing.
case variable [anything1 ilist1 anything2
ilist2] [Observer, Turtle]
Checks if the first argument variable is equal to any of the
anythings in the list. If it is equal, the corresponding ilist
is executed and control skips to the end of the case statement.
If nothing matches, no ilists are executed and control skips to
the end of the case statement.
Sample usage:
case temperature
[
"cold" [show "boy, it's cold!"]
"warm" [show "mmmm. nice."]
"hot" ["wow, it's hot!"]
]
every number list to run [Observer, Turtle]
every is just like loop, in that it runs its list
to run forever, but it waits number seconds between each
iteration.
if condition ilist [Observer, Turtle]
Do ilist if condition reports true.
ifelse condition ilist1 ilist2 [Observer, Turtle]
Do ilist1 if condition reports true, otherwise do
ilist2.
ignore whatever [Observer, Turtle]
Ignores the statement immediately following it.
let variable value [Observer, Turtle]
Declares variable as a local variable and assigns value
to it. All variables must have names which begin with a colon. See the Variables
page for more information on local variables.
Example:
let [:myvar 6]
loop ilist [Observer, Turtle]
Do ilist forever.
output something [Observer, Turtle]
Exits the current procedure and returns something
repeat number ilist [Observer, Turtle]
Do ilist number times.
resett, reset-timer[Observer, Turtle]
Resets the timer.
startup [Observer]
This is a reserved observer procedure name. Anything within the startup
procedure will be executed each time the project is opened.
stop [Observer, Turtle]
Tells the current procedure to stop running.
stopall [Observer, Turtle]
Tells all everything to stop running, including procedures, buttons, monitors, and command centers.
timer [Observer, Turtle]
Reports the curent value of the timer.
wait number [Observer, Turtle]
Caller waits number seconds before continuing.
wait-until predicate [Observer, Turtle]
Caller waits until predicate is true.