> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arc.cdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# arc:enum

> Iterates over the attributes of an item, a delimited list, a range of values, or the values of a multi-valued attribute, executing the body for each element.

export const siteNameShort = "Arc";

Use the `arc:enum` keyword to enumerate over the attributes in an item, a delimited list, a supplied range of values, or the values of a multi-valued attribute. The body of `arc:enum` is executed for each element of the set that is being iterated upon.

## Parameters

* **item**: The name of the item whose attributes you want to iterate over.
* **attr**: The expression to match that specifies which attributes are iterated over. For example, `arc:*`. You can also provide this parameter to iterate over the values of a multi-valued attribute.
* **prefix**: The prefix based on which the item is enumerated.
* **expand**: The boolean value that specifies how `arc:enum` behaves when multi-valued attributes are encountered. If expand is set to `true`, the body of `arc:enum` is executed once for each value of the attribute. If `false`, all values are concatenated in a single string value, and a single iteration is performed. By default, `arc:enum` does not expand all values.
* **sep\[arator]**: The separator to use to concatenate values of a multi-valued attribute if the **expand** parameter is `false`. This parameter is also used to tokenize the values in a list if listseparator is not defined. The default value is the new-line character (`\n`).
* **list**: The list of separated values to enumerate over. For example, if the list of values is `violet, indigo, blue, green, yellow, orange, red` and the separator is a comma (`,`), the scope of `arc:enum` is executed for each color in the rainbow.
* **range**: The range of numbers or characters to enumerate over in ascending or descending order; for example, `a..z` or `Z..A`.

<Note>You can specify either the **range** or the **item** parameter, but not both. Attributes are enumerated in alphabetical order.</Note>

## Control Attributes

* **\_attr**: The name of the attribute being iterated over. When you are iterating over the values of a multi-valued attribute, the attribute name is the same except that it also has the index as part of the name. The index is separated from the name by the hash symbol (`#`). For example, `name#1`, `name#2`, and so on.
* **\_index**: The index at which the attribute appears in an item, or the position of the list element currently being enumerated over.
* **\_value**: The value of the attribute being iterated over. For a multi-valued attribute, the **expand** and **separator** parameter settings determine whether \_value is a reference to one attribute value or a reference to all attribute values.
* **\_count**: The number of values in an attribute or in a list.
* **\_separator**: The separator used to separate the values in a list.

## Examples

Display the attribute names and attribute values of the item named `input`:

```xml theme={null}
<arc:set item="input" attr="Greeting" value="Hello" />
<arc:set item="input" attr="Goodbye" value="See ya" />
<arc:enum item="input">
  [_attr] is [_value]
  <br/>
</arc:enum> 
```

```
goodbye is See ya greeting is Hello
```

To enumerate over a list of values, use the **list** and **separator** parameters. For example, the following code lists the colors specified in the `colors` attribute:

```xml theme={null}
<arc:set attr="colors" value="violet, indigo, blue, green, yellow, orange, red"/>
<arc:enum list="[colors]" separator=",">
  [_value] 
</arc:enum>
```

To enumerate over a range of values, use the **range** parameter. This example lists the character set from `a to z`, from `Z to A`, and the numbers from `1 to 25`:

```xml theme={null}
<arc:enum range="a..z">
  [_value] 
</arc:enum>
<arc:enum range="Z..A">
  [_value] 
</arc:enum>
<arc:enum range="1..25">
  [_value] 
</arc:enum>
```

To enumerate over all the values of a multi-valued attribute, use the **\_attr** control attribute to specify a multi-valued attribute and set the **expand** parameter to `true`:

```xml theme={null}
<arc:set attr="foo.email#1" value="joe@mycompany.com"/>
<arc:set attr="foo.email#2" value="john@mycompany.com"/>
<arc:enum attr="foo.email" expand="true">
    ([_index]) [_attr] -> [_value]
</arc:enum>
```

The example above results in the following output:

```
(1) email#1 -> joe@mycompany.com (2) email#2 -> john@mycompany.com
```

## See Also

* [arc:break](./op-arc-break): Break out of [arc:call](./op-arc-call) or `arc:enum` iterations.
* [arc:continue](./op-arc-continue): Skip an [arc:call](./op-arc-call) or `arc:enum` iteration.
* [arc:first](./op-arc-first): Provide special processing in the first iteration.
* [arc:last](./op-arc-last): Provide special processing in the last iteration.
