# Using Tag Value in OPC Item Path

**URL:** <https://forum.inductiveautomation.com/t/using-tag-value-in-opc-item-path/10148>\
**Category:** Ignition\
**Created:** [June 18, 2015, 3:16pm UTC](https://forum.inductiveautomation.com/t/using-tag-value-in-opc-item-path/10148 "2015-06-18T15:16:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trent.Boudreaux](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/trent.boudreaux/32/4138_2.png) [@Trent.Boudreaux](https://forum.inductiveautomation.com/u/Trent.Boudreaux)\
**Post date:** [June 18, 2015, 3:16pm UTC](https://forum.inductiveautomation.com/t/using-tag-value-in-opc-item-path/10148/1 "2015-06-18T15:16:23Z")

</div>

Is it possible to use the value of a tag in a UDT in an OPC Item Path of another tag in the same UDT?

ex: OPC Item Path: [MyDevice]1.HRUS{[.]Address}

If not, is there another way to avoid hard coding Addresses for each tag, when there is a consistent format based on an index.

ie:  
Parameter 1 Value is on Register 10, Quality is on Register 11, and ID is on Register 12.  
Parameter 2 Value is on Register 20, Quality is on Register 21, and ID is on Register 22.  
Parameter 3 Value is on Register 30, Quality is on Register 31, and ID is on Register 32.  
etc.

Thank You,  
-Trent

---

<div class="post-metadata">

**Author:** ![Tim](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tim/32/3361_2.png) [@Tim](https://forum.inductiveautomation.com/u/Tim)\
**Post date:** [June 18, 2015, 5:32pm UTC](https://forum.inductiveautomation.com/t/using-tag-value-in-opc-item-path/10148/2 "2015-06-18T17:32:01Z")

</div>

I’m not sure I understand your application. You could access the tags directly with scripting and possibly use that to end up with what you need.

[code]index = system.tag.read(“Folder\Index”).value

tagPath0 = (’[PLC]Array[%d].value1’) % index  
tagPath1 = (’[PLC]Array[%d].value2’) % index  
tagPath2 = (’[PLC]Array[%d].value3’) % index

tag = system.opc.readValues(‘Ignition OPC-UA Server’, [tagPath0,tagPath1,tagPath2])

value1 = tag[0].value  
value2 = tag[1].value  
value3 = tag[2].value  
[/code]

---

<div class="post-metadata">

**Author:** ![Trent.Boudreaux](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/trent.boudreaux/32/4138_2.png) [@Trent.Boudreaux](https://forum.inductiveautomation.com/u/Trent.Boudreaux)\
**Post date:** [June 18, 2015, 5:50pm UTC](https://forum.inductiveautomation.com/t/using-tag-value-in-opc-item-path/10148/3 "2015-06-18T17:50:24Z")

</div>

Thanks for the reply Tim.  
Your example is helpful.

I’ve found two other threads with similar questions.  
[ul][li][Reference UDT Member within same UDT](https://inductiveautomation.com/forum/viewtopic.php?f=70&t=11721&p=45330)[/li]  
[li][Indirect Addressing through an Expression or an OPC tag](https://inductiveautomation.com/forum/viewtopic.php?f=70&t=12316&p=44730)[/li][/ul]

Similar approach, but with expression tags instead of script.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 18, 2015, 7:21pm UTC](https://forum.inductiveautomation.com/t/using-tag-value-in-opc-item-path/10148/4 "2015-06-18T19:21:52Z")

</div>

When you set up a UDT you can specify parameters that will be substituted in the address. Each UDT instance has its own parameter values. In your case, you’d want a parameter for the start address of each unit. The ‘Value’ uses {start} directly, ‘Quality’ uses {start+1}, and ‘ID’ uses {start+2}. The parameter cannot come from a live process values, but it doesn’t sound like you need that. Look at [this](https://inductiveautomation.com/forum/viewtopic.php?f=70&t=13999) topic for a similar situation and UDT example file.

---

<div class="post-metadata">

**Author:** ![jcroxton](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jcroxton](https://forum.inductiveautomation.com/u/jcroxton)\
**Post date:** [April 16, 2018, 8:13am UTC](https://forum.inductiveautomation.com/t/using-tag-value-in-opc-item-path/10148/5 "2018-04-16T08:13:30Z")

</div>

I am trying to create a datatype which is able to use parameters to dynamically create an OPC Item Path where parameters are: DB for db number and Size and Index,

Problem is the value of the Item Path is not able to be an expression so Size \* Index for the offset gets evaluated a 2\*3 rather than 6.

Is there any way around this?

Is scripting the only way? Should I perhaps have an memory array tag for an entire DB that gets updated on a cyclic script? My Data Type tags would the reference indexed values of this array. This sounds revolting. How would I write out values.

Alternatively, does the Siemens driver support arrays at all?

Thanks everyone.

John

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 16, 2018, 12:52pm UTC](https://forum.inductiveautomation.com/t/using-tag-value-in-opc-item-path/10148/6 "2018-04-16T12:52:38Z")

</div>

Whatever else you come up with (I am not a Siemens expert), you should know that Ignition doesn’t have array tags, regardless what driver is involved. It has what it _ **calls** _ array tags, but they are really just bit arrays expanding the contents of single elements of an integer type.
