KUIML
Blue Cat's User Interface Programming Language
REPEAT

Description

This element is a static repeat loop. It can be used to repeat several times the same piece of code, with changes managed by an index variable for each instance. There are several ways ro define the index for the loop, either with numbers or with a list of strings.

Attributes

Name Value Type Default Value Description Comment V. Exp.

index_name

string

index

name of the variable used for the index in the loop.

for nested repeats it is necessary to define different names for the index variable to avoid conflicts.

1.7

No

count

integer or a Math Formula using previously defined variables

0

number of repeats.

This is number of repeats for the code contained inside the REPEAT element.

1.7

No

start

integer or Math Formula using previously defined variables

0

start value for the index published in the repeat loop.

To be used with the count attributes. Defines the list of values for the index variable.

1.7

No

index_list

list of semi-column separated values (strings)

empty

List of values for the index variable. Also implies the number of repeats.

This attribute overrides the start/count attributes.

1.7

No

Syntax

The following code:

<REPEAT count="2" start="1">
	<ELEMENTA attribute_a="$index$"/>
</REPEAT>

Is equivalent to:

<ELEMENTA attribute_a="1"/>
<ELEMENTA attribute_a="2"/>

Similarly, using the index_list attribute instead, the following code:

<REPEAT index_list="A;B">
	<ELEMENTA attribute_a="$index$"/>
</REPEAT>

Is equivalent to:

<ELEMENTA attribute_a="A"/>
<ELEMENTA attribute_a="B"/>

And you can modify the index_name attribute for nested loops, so that the following code:

<REPEAT count="2" start="1">
  <REPEAT index_name="sub_index" count="2" start="1">
    <ELEMENTA attribute_a="$index$-$sub_index$"/>
  </REPEAT>
</REPEAT>

Is equivalent to:

<ELEMENTA attribute_a="1-1"/>
<ELEMENTA attribute_a="1-2"/>
<ELEMENTA attribute_a="2-1"/>
<ELEMENTA attribute_a="2-2"/>

A formula can be used to compute the index and start values. For example the following code:

<VARIABLE id="a" value="1">
<VARIABLE id="b" value="0">
<REPEAT count="$a$*2" start="$b$+1">
  <ELEMENTA attribute_a="$index$"/>
</REPEAT>

Is equivalent to:

<ELEMENTA attribute_a="2"/>
<ELEMENTA attribute_a="3"/>