repeatselect
<repeatselect> = repeatselect*, select+.
Name | Type | Default |
---|---|---|
name | the name to be used for the substitution variable | Required |
list | a list of values to iterate over | Optional |
from | the starting value for a numeric iteration | Optional |
to | the ending value for a numeric iteration | Optional |
by | the step size for a numeric iteration | Optional |
<repeatselect> elements allow for the repetition of the enclosed <select> statements with variable substitutions. The <repeatselect> element specifies values to iterate over, either as a list of items or as a numeric iteration similar to a do loop in other programming languages. The <repeatselect> element will first capture all enclosed <select> elements. The <repeatselect> directive will iterate over all of the repetition values, perform variable substitutions on the enclosed elements, and provide the results to the Matrix Builder for processing.
Variable substitution may occur in any place within the <repeatseelct> element where expressions are allowed. The substitution is invoked by using the getEnv function, The value passed to the function is the literal 'repeat.' and the name attribute of the enclosing <repeatselect> element (for example if the name attribute of the <repeatselect> element is 'basis' then the argument to the getEnv function would be 'repeat.basis').
The <repeatselect> element is a convenience feature, allowing a concise definition of a set of enclosed <select> elements that vary in only a few respects.
<repeatselect> elements may be nested, allowing for the expression of all combinations of multiple factors.
These elements contain repeatselect: ForestModel, repeatselect.
The following elements can occur in repeatselect: repeatselect, select.
name
This attribute provides an alphanumeric name label that can be used to reference the iteration value of the repeatselect loop. The name being used must be unique within the scope of all enclosing and enclosed repeat blocks.
list
This attribute provides a list of values to be iterated over. The value provided will be interpreted as an expression that will be evaluated when the looping begins. If the result of the evaluation is a list data type then the elements of the list will be used. If the result of the evaluation is a string data type then the string will be split on comma characters and the loop will iterate over the resulting string parts. To convert the string parts to a number use one of the casting conversion functions (int() or number()).
from
This attribute provides an expression that evaluates to the starting value of a numeric looping iteration.
to
This attribute provides an expression that evaluates to the ending (inclusive) value of a numeric looping iteration.
by
This attribute provides an expression that evaluates to the step size value that is used to increment through a numeric iteration. If not specified the default value of the 'by' attribute is 1.
The list attribute is optional, but either 'list' or 'from' and 'to' must be provided. It is an error to provide both 'list' and 'from', 'to' or 'by'.
Repeatselect can help simplify a model by reducing repetitive sections with a loop. For example,
<repeatselect name="age" from="8" to="18"> <select statement="status in 'Thinned'+getEnv('repeat.age') and regime in FertYes"> <track> <treatment label="MRFert" minage="getEnv('repeat.age')+1" maxage="getEnv('repeat.age')+1" adjust="R" retain="5"> <produce> <assign field="treatment" value="'MRFert'"/> </produce> <transition> <assign field="status" value="status+'FERT'"/> </transition> </treatment> </track> </select> </repeatselect>
In the example above, a mid-rotation fertilization treatment may be applied one year after thinning, from ages 8 to 18. This loop will set the select condition to stands with a status of being thinned in the designated year, set the operability limits to the next year after the thinning, and update the status to indicate that the thinning occurred. The getEnv function is used to retrieve the loop value and substitute it the appropriate locations. Without the <repeatselect> loop all of the enclosed elements would have to be repeated 11 times.
Repeatselect elements may be nested, in which case all combinations of values are processed:
<repeatselect name="treat" list="'U120075,U130085,U140095'" > <repeatselect name="start" from="1" to="4"> <select statement="column('f'+getEnv('repeat.treat')+'_'+getEnv('repeat.start')) ge 1"> <track> <treatment label="getEnv('repeat.treat')+'_'+getEnv('repeat.start')" adjust="R"> <produce> <assign field="activity" value="getEnv('repeat.treat')"/> </produce> <transition> <assign field="Regime" value="getEnv('repeat.treat')+'_'+getEnv('repeat.start')"/> </transition> </treatment> </track> </select> </repeatselect> </repeatselect>
In this example two <repeatselect> elements iterate over the variables 'treat' and 'start'. The values retrieved by the getEnv function are used separately and in combination. In the select statement the two values are used in combination with the column function to test the value of a stratification variable.