Learn R Programming

RNetLogo (version 0.9.2)

NLDoCommandWhile: Repeated execution of a command in the referenced NetLogo instance while a reporter returns TRUE.

Description

NLDoCommandWhile function is used to execute a NetLogo command (submitted as a string) in the submitted NetLogo instance more than one time. It works like NLCommand but will be repeated while the reporter returns TRUE.

Usage

NLDoCommandWhile(condition, ..., nl.obj=NULL)

Arguments

condition
A string with a NetLogo conditional reporter.
...
An undefined number of string(s) with the NetLogo command(s) to be executed. See NLCommand for details.
nl.obj
(optional) A variable holding a reference to a NetLogo instance created with NLStart.

Value

  • No return value.

Details

This function is used to execute a command for more than one time. It could be used to run a simulation (e.g. calling "go") while a variable is lower a boundary value.

See Also

NLCommand, NLDoCommandWhile, NLReport

Examples

Run this code
nl.path <- "C:/Program Files/NetLogo 4.1.3"
NLStart(nl.path)
model.path <- "/models/Sample Models/Earth Science/Fire.nlogo"
NLLoadModel(paste(nl.path,model.path,sep=""))
NLCommand("setup")
NLDoCommandWhile("burned-trees < 2200", "go")

Run the code above in your browser using DataLab