NLDoCommandWhile {RNetLogo} | R Documentation |
Repeats a command in the referenced NetLogo instance while a reporter returns TRUE
.
Description
NLDoCommandWhile
function executes a NetLogo command (submitted as a string)
in the submitted NetLogo instance more than one time. It works like NLCommand
but will
be repeated as long as the reporter returns TRUE
.
Usage
NLDoCommandWhile(condition, ..., max.minutes=10, 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. |
max.minutes |
(optional) If |
nl.obj |
(optional) A string identifying a reference to a NetLogo instance created with |
Details
This function is used to execute a command for more than one time. It can be used, for example, to run a simulation (by calling "go") while a variable is below some limit.
The condition is evaluated before the submitted commands are executed. If the condition is FALSE
at the first evaluation, the commands will never be executed.
Attention: Make sure that the condition switches from TRUE
to FALSE
sometime,
otherwise you will run an endless loop (which is stopped after 10 minutes by default, see argument max.minutes
).
Value
No return value.
Author(s)
Jan C. Thiele <rnetlogo@gmx.de>
See Also
NLCommand
,
NLDoCommandWhile
,
NLReport
Examples
## Not run:
nl.path <- "C:/Program Files/NetLogo 6.0/app"
NLStart(nl.path)
model.path <- "/models/Sample Models/Earth Science/Fire.nlogo"
NLLoadModel(paste(nl.path,model.path,sep=""))
NLCommand("setup")
NLDoCommandWhile("burned-trees < 500", "go")
## End(Not run)