Name

repeattreatment — repeat the enclosed treatment block with variable substitution

Synopsis

Content Model

   <repeattreatment> = repeattreatment*, track+.  
    

Attributes

NameTypeDefault
namethe name to be used for the substitution variableRequired
lista list of values to iterate overOptional
fromthe starting value for a numeric iterationOptional
tothe ending value for a numeric iterationOptional
bythe step size for a numeric iterationOptional

Description

<repeattreatment> elements allow for the repetition of the enclosed <treatment> statements with variable substitutions. The <repeattreatment> 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 <repeattreatment> element will first capture all enclosed <treatment> elements. The <repeattreatment> 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 <repeattreatment> 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 <repeattreatment> element (for example if the name attribute of the <repeattreatment> element is 'basis' then the argument to the getEnv function would be 'repeat.basis').

The <repeattreatment> element is a convenience feature, allowing a concise definition of a set of enclosed <treatment> elements that vary in only a few respects.

<repeattreatment> elements may be nested, allowing for the expression of all combinations of multiple factors.

Parents

These elements contain repeattreatment: track, repeattreatment.

Children

The following elements can occur in repeattreatment: repeattreatment, treatment.

Attributes

name

This attribute provides an alphanumeric name label that can be used to reference the iteration value of the repeattreatment 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'.

See Also

repeattreatment.

Examples

repeattreatment can help simplify a model by reducing repetitive sections with a loop. For example,

  <select statement="strata in Act and status in 'Unthinned'">
    <track>
     <repeattreatment name='age' from='15' to='30'>
      <treatment label="'Thin'+getEnv('repeat.age')" 
                 minage="getEnv('repeat.age')" maxage="getEnv('repeat.age')">
        <produce>
          <assign field="treatment" value="'Thin'+getEnv('repeat.age')"/>
        </produce>
        <transition>
          <assign field="status" value="'Thinned'+getEnv('repeat.age')"/>
        </transition>
      </treatment>
     </repeattreatment>
    </track>
  </select>

In the example above thinning options are provided from ages 15 to 30 inclusive. All stands in the 'Unthinned' status are eligible. This loop will set the set the treatment name and the minimum and maximum operability ages. The treatment field is assigned a code indicating the age of the thinning, and this could be used to determine the thinning yields, costs and other characteristics. The status field is updated with a status condition code indicating the age of the thinning, which could be used to determine the next eligible treatment. The getEnv function is used to retrieve the loop value and substitute it the appropriate locations. Without the <repeattreatment> loop all of the enclosed elements would have to be repeated 16 times.