if1.0

if boolean [ commands ]

If boolean reports true then the commands are run, otherwise the commands are not run if boolean reports false.

If boolean reports a value other than true or false a runtime error will occur.

The boolean may report a different value for different agents when used with a primitive like ask, so some agents may run commands and others don't.

ask turtles [
  if xcor > 0 [ set color blue ]
  ;; turtles in the right half of the world
  ;; turn blue
]

See also ifelse, ifelse-value.

Take me to the full NetLogo Dictionary