# arc:enum Can it take a dynamic range?

**URL:** <https://community.cdata.com/t/arc-enum-can-it-take-a-dynamic-range/813>\
**Category:** CData Arc\
**Tags:** enum, question\
**Created:** [July 3, 2024, 2:22pm UTC](https://community.cdata.com/t/arc-enum-can-it-take-a-dynamic-range/813 "2024-07-03T14:22:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![russell-jerseypost](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@russell-jerseypost](https://community.cdata.com/u/russell-jerseypost)\
**Post date:** [July 3, 2024, 2:22pm UTC](https://community.cdata.com/t/arc-enum-can-it-take-a-dynamic-range/813/1 "2024-07-03T14:22:41Z")

</div>

In a Script connector, based on a value I’ve calculated earlier in the&nbsp;script ( **numberofpallets** ) , I need to repeat an&nbsp;XML structure multiple times. The only thing that changes is the **\<PalletID\>**

I’m trying this

```xml
<arc:set attr="output.data"> <arc:enum range="1..[output.header:numberofpallets]"> <OrderStatusUpdate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <EventTime>2024-07-03T13:03:00.0000+01:00</EventTime> <OrderNo>200766</OrderNo>... <Longitude>Not Available</Longitude> <PalletID>[_index]</PalletID> </OrderStatusUpdate> </arc:enum></arc:set>

```

But get the error “Invalid range, e.g of valid ranges are 1..20, a..z, A..z, z..a etc :”

---

<div class="post-metadata">

**Author:** ![russell-jerseypost](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@russell-jerseypost](https://community.cdata.com/u/russell-jerseypost)\
**Post date:** [July 3, 2024, 3:16pm UTC](https://community.cdata.com/t/arc-enum-can-it-take-a-dynamic-range/813/2 "2024-07-03T15:16:21Z")

</div>

Okay, this is crude, but it works up to 99 pallets…

```xml
<arc:set attr="data.pallets" value=""/><arc:enum range="0..99"> <arc:if attr="output.header:numberofpallets" value="[_value]" operator="greaterthan"> <arc:set attr="data.pallets"> [data.pallets] <OrderStatusUpdate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <EventTime>[data.EventTime]</EventTime> <OrderNo>[data.OrderNo]</OrderNo> <CustomerOrderReference>[data.CustomerOrderReference]</CustomerOrderReference> <StatusCode>[data.StatusCode]</StatusCode> <StatusName>[data.StatusName]</StatusName> <WaybillNo>[data.WaybillNo]</WaybillNo> <Notes>[data.Notes]</Notes> <SignedBy>[data.SignedBy]</SignedBy> <Signature>[data.Signature]</Signature> <Latitude>[data.Latitude]</Latitude> <Longitude>[data.Longitude]</Longitude> <PalletID>[_value|add(1)]</PalletID> </OrderStatusUpdate>' </arc:set> </arc:if></arc:enum><arc:set attr="output.data" value="<PalletsStatuses>[data.pallets]</PalletsStatuses>"/><arc:push item="output"/>

```

---

<div class="post-metadata">

**Author:** ![James\_B](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/james_b/32/1688_2.png) [@James\_B](https://community.cdata.com/u/James_B)\
**Post date:** [July 3, 2024, 7:45pm UTC](https://community.cdata.com/t/arc-enum-can-it-take-a-dynamic-range/813/3 "2024-07-03T19:45:32Z")

</div>

You should be able to evaluate an expression just about anywhere including the range in an enum - this works for me:

```xml
<arc:set attr="output.header:numberofpallets" value="10" /><arc:enum range="1..[output.header:numberofpallets]"> <arc:set attr="output.filename" value="[_value].txt" /> <arc:push item="output" /></arc:enum>

```

Are you sure that output.header:numberofpallets was set to an integer value earlier in the script?

---

<div class="post-metadata">

**Author:** ![russell-jerseypost](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@russell-jerseypost](https://community.cdata.com/u/russell-jerseypost)\
**Post date:** [July 4, 2024, 3:21pm UTC](https://community.cdata.com/t/arc-enum-can-it-take-a-dynamic-range/813/4 "2024-07-04T15:21:32Z")

</div>

Thanks James

_ **numberofpallets** _ was calculated using **| add()**&nbsp; so I presume&nbsp;it is an integer

---

<div class="post-metadata">

**Author:** ![James\_B](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/james_b/32/1688_2.png) [@James\_B](https://community.cdata.com/u/James_B)\
**Post date:** [July 5, 2024, 7:39pm UTC](https://community.cdata.com/t/arc-enum-can-it-take-a-dynamic-range/813/5 "2024-07-05T19:39:20Z")

</div>

Hi Russell,

Would you be able to provide the whole code here? I could not see where the value was initialized. You can always use arc:throw as a makeshift mechanism for stepping through the script:

```xml
<arc:throw code="x" desc="NumberOfPallets is [output.header:numberofpallets | def('undefined')]" /><arc:set attr="data.pallets" value=""/><arc:enum range="0..99"> <arc:if attr="output.header:numberofpallets" value="[_value]" operator="greaterthan">

```

If you do this, you’ll see an exception with the value that output.header:numberofpallets currently has - is that an integer?
