# Nested UDT and getBit

**URL:** <https://forum.inductiveautomation.com/t/nested-udt-and-getbit/106052>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [May 8, 2025, 3:36pm UTC](https://forum.inductiveautomation.com/t/nested-udt-and-getbit/106052 "2025-05-08T15:36:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![msteele](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/msteele/32/77889_2.png) [@msteele](https://forum.inductiveautomation.com/u/msteele)\
**Post date:** [May 8, 2025, 3:36pm UTC](https://forum.inductiveautomation.com/t/nested-udt-and-getbit/106052/1 "2025-05-08T15:36:54Z")

</div>

I have a UDT let's call "Module" which contains the following...

- 7+ nested UDTs let's call "Branch".
- Bitfields/AlarmRegister, a bitpacked alarm register with alarms for each of the 7 branches.

Within the nested branch UDT, I have a boolean expression tag with `getBit({relPathToContainingUdt/Bitfields/AlarmRegister},{branchNum})` to pull the correct alarm. This results in `Error_ExpressionEval`

Is there no way to reference within a nested UDT to a tag in the containing UDT at runtime?

---

<div class="post-metadata">

**Author:** ![Arnaud\_Declerck](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/arnaud_declerck/32/44872_2.png) [@Arnaud\_Declerck](https://forum.inductiveautomation.com/u/Arnaud_Declerck)\
**Post date:** [May 8, 2025, 3:55pm UTC](https://forum.inductiveautomation.com/t/nested-udt-and-getbit/106052/2 "2025-05-08T15:55:18Z")

</div>

hi @msteele

The getBit expression take a number and a position as input.  
Therefor when you have the path to your alarm register you need to read the tag value with the tag expression.  
Here an example  
`getBit(tag(concat(replace({PathToParentFolder},{InstanceName},''),'AlarmRegister')),1)`

be aware that is the bit into your branch udt in neeted into a folder structure, you will need to replace the instanceName but also the folder structure.  
1 is the bit position you want to read.  
This can come from a parameter you set on each branch udt into your module udt.  
For example here i use my instance name to dynamically decide the position. you just need to make sure it's an integer.

```python
getBit(tag(concat(replace({PathToParentFolder},{InstanceName},''),'AlarmRegister')),toInt({InstanceName}))

```

Here the result

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/3/431d1d18b1caf26151d850f6169d1815b80c40ab.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/1/118b67d59e4f02f4415a71dcb247bc329bc5faf9.png)  
Hope it helps  
regards  
Arnaud

---

<div class="post-metadata">

**Author:** ![msteele](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/msteele/32/77889_2.png) [@msteele](https://forum.inductiveautomation.com/u/msteele)\
**Post date:** [May 8, 2025, 4:28pm UTC](https://forum.inductiveautomation.com/t/nested-udt-and-getbit/106052/3 "2025-05-08T16:28:31Z")

</div>

Ah, that makes sense. I was hoping an extra `../` after the `{[.]` would get parsed within the instance and allow me to hop up to a reference in the containing UDT. I was trying to avoid using tag() and the performance hit. If I had to do that, I might as well just pull my bitmapped register to every nested instance, then use `getBit()` into the appropriate bit. Thanks for the clarification about relative tagPath behavior across UDTs!
