# Indirect Tag binding and the Case Statement

**URL:** <https://forum.inductiveautomation.com/t/indirect-tag-binding-and-the-case-statement/100768>\
**Category:** Ignition\
**Created:** [January 11, 2025, 3:54pm UTC](https://forum.inductiveautomation.com/t/indirect-tag-binding-and-the-case-statement/100768 "2025-01-11T15:54:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josh\_Nelson](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@Josh\_Nelson](https://forum.inductiveautomation.com/u/Josh_Nelson)\
**Post date:** [January 11, 2025, 3:54pm UTC](https://forum.inductiveautomation.com/t/indirect-tag-binding-and-the-case-statement/100768/1 "2025-01-11T15:54:05Z")

</div>

Hello,

I am attempting to pull values from an (offset array number index number). Below is listed the code that I have. However, you'll see from the snip that my [.]Cut Type keeps getting returned rather than the value I'm looking for. I'm sure it's just a structuring problem so I wondered if someone could help me with the structuring. It's probably something simple but I am at a loss right now.

```python
case(
	{[.]Cut Type},
	1, tag("{[.]../../OffsetArrays/OffsetArray" + {[.]../../ArrayNumber}) [{[.]../.. IndexNumber 3}],
	2, tag("{[.]../../OffsetArrays/OffsetArray" + {[.]../../ArrayNumber}) [{[.]../../IndexNumber 1}],
	3, tag("{[.]../../OffsetArrays/OffsetArray" + {[.]../../ArrayNumber}) [{[.]../../IndexNumber 1}],
	0,
)

```

 ![Capture1](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/6/a6c2f893ce34e41fb009e9460b720ef54d6a8e67.png)  
 ![Capture2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/3/838c80270b70b18447d05635eab69f7a0fac760c.png)

---

<div class="post-metadata">

**Author:** ![Josh\_Nelson](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@Josh\_Nelson](https://forum.inductiveautomation.com/u/Josh_Nelson)\
**Post date:** [January 11, 2025, 3:59pm UTC](https://forum.inductiveautomation.com/t/indirect-tag-binding-and-the-case-statement/100768/3 "2025-01-11T15:59:36Z")

</div>

Fixed! Thanks for that! Still having the same issue inside the designer.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 11, 2025, 4:00pm UTC](https://forum.inductiveautomation.com/t/indirect-tag-binding-and-the-case-statement/100768/4 "2025-01-11T16:00:22Z")

</div>

> [@Josh\_Nelson](#):
>
> However, you'll see from the snip that my [.]Cut Type keeps getting returned rather than the value I'm looking for.

I don't understand this. Can you add captions to the images to explain what you are showing us?

---

<div class="post-metadata">

**Author:** ![Josh\_Nelson](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@Josh\_Nelson](https://forum.inductiveautomation.com/u/Josh_Nelson)\
**Post date:** [January 11, 2025, 4:05pm UTC](https://forum.inductiveautomation.com/t/indirect-tag-binding-and-the-case-statement/100768/5 "2025-01-11T16:05:12Z")

</div>

What I'm attempting to display is the values you see from OffsetArray6(95/96/97/98). In this case, "B" from the UDT is attempting to call the value from either the Index Array 1 or 3 depending on "Cut Type" being either a 1, 2, or a 3. However, I'm having problems building the dynamic tag structure. You can see from the uploaded snip, that the "Array Number" and the "Index Number X" can have different values.

 ![Capture3](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/8/b89c0e3db3bdec43bf29d8fb133a083261f327c5.png)

---

<div class="post-metadata">

**Author:** ![Josh\_Nelson](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@Josh\_Nelson](https://forum.inductiveautomation.com/u/Josh_Nelson)\
**Post date:** [January 11, 2025, 4:06pm UTC](https://forum.inductiveautomation.com/t/indirect-tag-binding-and-the-case-statement/100768/6 "2025-01-11T16:06:41Z")

</div>

![Capture4](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/f/3f2d3eb079468d71ab5ac0307df1c51ca30ef591.png)

There you can see the "Cut Type" tag returning a 1. I want to evaluate the Cut Type value, and then decide via the case statement which Array# and Index# to build onto my "OffsetArray" tag.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 11, 2025, 4:15pm UTC](https://forum.inductiveautomation.com/t/indirect-tag-binding-and-the-case-statement/100768/7 "2025-01-11T16:15:01Z")

</div>

I'm still looking at it.  
I've noticed an incorrect comma in the original expression but I'd expect that to give you an expression error in Tag Browser. Fix it anyway!

```python
case(
	{[.]Cut Type},
	1, tag("{[.]../../OffsetArrays/OffsetArray" + {[.]../../ArrayNumber}) [{[.]../../IndexNumber 3}],
	2, tag("{[.]../../OffsetArrays/OffsetArray" + {[.]../../ArrayNumber}) [{[.]../../IndexNumber 1}],
	3, tag("{[.]../../OffsetArrays/OffsetArray" + {[.]../../ArrayNumber}) [{[.]../../IndexNumber 1}],
	0, // <---- Comma shouldn't be there.
)

```

---

<div class="post-metadata">

**Author:** ![Josh\_Nelson](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@Josh\_Nelson](https://forum.inductiveautomation.com/u/Josh_Nelson)\
**Post date:** [January 11, 2025, 4:18pm UTC](https://forum.inductiveautomation.com/t/indirect-tag-binding-and-the-case-statement/100768/8 "2025-01-11T16:18:01Z")

</div>

Fixed! I want to develop good habits so I'm open to any and all suggestions.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 11, 2025, 4:38pm UTC](https://forum.inductiveautomation.com/t/indirect-tag-binding-and-the-case-statement/100768/9 "2025-01-11T16:38:50Z")

</div>

As a debug, add a string tag, copy the binding over and edit out the `tag` function so that it returns the string path.

```python
case(
	{[.]Cut Type},
	1, ("{[.]../../OffsetArrays/OffsetArray" + {[.]../../ArrayNumber}) [{[.]../../IndexNumber 3}],
	2, ("{[.]../../OffsetArrays/OffsetArray" + {[.]../../ArrayNumber}) [{[.]../../IndexNumber 1}],
	3, ("{[.]../../OffsetArrays/OffsetArray" + {[.]../../ArrayNumber}) [{[.]../../IndexNumber 1}],
	0
)

```

Check carefully that the path is correct.

---

<div class="post-metadata">

**Author:** ![Josh\_Nelson](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@Josh\_Nelson](https://forum.inductiveautomation.com/u/Josh_Nelson)\
**Post date:** [January 11, 2025, 5:22pm UTC](https://forum.inductiveautomation.com/t/indirect-tag-binding-and-the-case-statement/100768/10 "2025-01-11T17:22:59Z")

</div>

I did that and I get a return value of 2.0

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 11, 2025, 6:46pm UTC](https://forum.inductiveautomation.com/t/indirect-tag-binding-and-the-case-statement/100768/11 "2025-01-11T18:46:18Z")

</div>

```python
case(
	{[.]Cut Type},
    // ,--- unmatched {!
	1, tag("{[.]../../OffsetArrays/OffsetArray" + {[.]../../ArrayNumber}) [{[.]../../IndexNumber 3}],
	2, tag("{[.]../../OffsetArrays/OffsetArray" + {[.]../../ArrayNumber}) [{[.]../../IndexNumber 1}],
	3, tag("{[.]../../OffsetArrays/OffsetArray" + {[.]../../ArrayNumber}) [{[.]../../IndexNumber 1}],
	0
)

```

Is the unmatched '{' the problem? It shouldn't be there.
