NLDoCommandWhile: Repeats a command in the referenced NetLogo instance while a...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/NLDoCommandWhile.R

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

1
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 max.minutes > 0 the execution stops after the defined number of minutes (with an error). By default, all executions are stopped after 10 minutes, to prevent the execution of endless loops. If you need more time, increase the value. If you're sure what you do, you can set this value to 0. Then, it will run while the condition is true (i.e. endlessly when the condition is never met. In GUI mode, you can press "Tools –> Halt" in the NetLogo menu to interrupt a running process.). This can speed up the execution, because the time checking is not applied in this case.

nl.obj

(optional) A string identifying a reference to a NetLogo instance created with NLStart.

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

1
2
3
4
5
6
7
8
9
## 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)

RNetLogo documentation built on May 2, 2019, 9:29 a.m.