# Directly addressing OPC tag to Value property of numerical label

**URL:** <https://forum.inductiveautomation.com/t/directly-addressing-opc-tag-to-value-property-of-numerical-label/14918>\
**Category:** Ignition\
**Created:** [July 28, 2017, 12:44pm UTC](https://forum.inductiveautomation.com/t/directly-addressing-opc-tag-to-value-property-of-numerical-label/14918 "2017-07-28T12:44:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nkienzle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nkienzle/32/4902_2.png) [@nkienzle](https://forum.inductiveautomation.com/u/nkienzle)\
**Post date:** [July 28, 2017, 12:44pm UTC](https://forum.inductiveautomation.com/t/directly-addressing-opc-tag-to-value-property-of-numerical-label/14918/1 "2017-07-28T12:44:27Z")

</div>

Simply trying to directly address a value property in a numeric label to an OPC path. Not a problem when a tag is created in the project, but I want to read tags directly without having to add them in the project.

Tried to use this in the expression property binding, but from what I can tell it isn’t supported? (might be wrong here) Looks like scripting allows for this, but there has to be an event to trigger the scripting which I’d like to avoid. Here is the syntax I was using:

system.opc.readvalue(“Ignition OPC UA”,"[Controller\_Example]Tag\_Name\_Example])

What am I missing here?

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [July 28, 2017, 2:59pm UTC](https://forum.inductiveautomation.com/t/directly-addressing-opc-tag-to-value-property-of-numerical-label/14918/2 "2017-07-28T14:59:45Z")

</div>

It looks like you just have the syntax wrong

> system.opc.readValue('Ignition OPC-UA Server','[Controller]TagAddress').value

---

<div class="post-metadata">

**Author:** ![nkienzle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nkienzle/32/4902_2.png) [@nkienzle](https://forum.inductiveautomation.com/u/nkienzle)\
**Post date:** [July 28, 2017, 3:02pm UTC](https://forum.inductiveautomation.com/t/directly-addressing-opc-tag-to-value-property-of-numerical-label/14918/3 "2017-07-28T15:02:37Z")

</div>

That syntax does not work for expressions.

Scan Error: Illegal character .\> (Line 1, Char 7)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 28, 2017, 3:13pm UTC](https://forum.inductiveautomation.com/t/directly-addressing-opc-tag-to-value-property-of-numerical-label/14918/4 "2017-07-28T15:13:16Z")

</div>

You would need to use the `runScript` expression function to do this. You can’t mix and match expression language with scripting language.

[https://docs.inductiveautomation.com:8443/display/DOC79/runScript](https://docs.inductiveautomation.com:8443/display/DOC79/runScript)

---

<div class="post-metadata">

**Author:** ![nkienzle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nkienzle/32/4902_2.png) [@nkienzle](https://forum.inductiveautomation.com/u/nkienzle)\
**Post date:** [July 28, 2017, 3:21pm UTC](https://forum.inductiveautomation.com/t/directly-addressing-opc-tag-to-value-property-of-numerical-label/14918/5 "2017-07-28T15:21:31Z")

</div>

Any reasoning behind having two different languages?

So basically, no, an OPC tag cannot be directly addressed in a numeric value quickly?

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [July 28, 2017, 3:27pm UTC](https://forum.inductiveautomation.com/t/directly-addressing-opc-tag-to-value-property-of-numerical-label/14918/6 "2017-07-28T15:27:59Z")

</div>

Ahh didn’t see the expression part.  
If you want to do this, just create a script in Project scope

```auto
def LabelOPC(tag):
	server = "Ignition OPC-UA Server"
	path = tag
	return system.opc.readValue(server, path).value

```

The in your expression call it like  
`runScript("project.SctiptContainerName.LabelOPC('[Controller]Tag')",2000)`

I would recommend against this though, as system.opc.readValue doesn’t create a tag subscription to the PLC.  
It will be slow and affect your client performance.
