# System.tag.read not returning a value?

**URL:** <https://forum.inductiveautomation.com/t/system-tag-read-not-returning-a-value/23892>\
**Category:** Ignition\
**Created:** [April 6, 2019, 4:29am UTC](https://forum.inductiveautomation.com/t/system-tag-read-not-returning-a-value/23892 "2019-04-06T04:29:41Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdixon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pdixon/32/6899_2.png) [@pdixon](https://forum.inductiveautomation.com/u/pdixon)\
**Post date:** [April 6, 2019, 4:29am UTC](https://forum.inductiveautomation.com/t/system-tag-read-not-returning-a-value/23892/1 "2019-04-06T04:29:41Z")

</div>

In the attached image I show a gateway script reading a tag TestBool, but no matter what the value if TestBool is I get the message “TestBool TRUE” in the log. If I put an illegitimate tag path in the read function I still return the same message every 10 seconds in the log. It appears read is not really reading the value of the tag. What am I doing wrong?

 ![ig_testboolscript_01](https://us1.discourse-cdn.com/inductiveautomation/original/2X/d/d478baf55c1f0c45f2bacacf5822f87b0bc8c1ed.jpeg)

---

<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:** [April 6, 2019, 11:46am UTC](https://forum.inductiveautomation.com/t/system-tag-read-not-returning-a-value/23892/2 "2019-04-06T11:46:01Z")

</div>

You need to get the value of the tag.  
system.tag.read(’[default]TagSplitter/TestBool’).value

[https://docs.inductiveautomation.com/display/DOC79/system.tag.read](https://docs.inductiveautomation.com/display/DOC79/system.tag.read)

---

<div class="post-metadata">

**Author:** ![pdixon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pdixon/32/6899_2.png) [@pdixon](https://forum.inductiveautomation.com/u/pdixon)\
**Post date:** [June 24, 2019, 12:31am UTC](https://forum.inductiveautomation.com/t/system-tag-read-not-returning-a-value/23892/3 "2019-06-24T00:31:07Z")

</div>

I find there are a number of combinations of specifying the TagPath and parameter reference that produce unexpected results. Below is a table that illustrates this:

 ![ig_tagpath_value_table](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/2d95d5ff664dcc5c6b0a2cb62a0238ddfee384a4.jpeg)

The best approach appears to be with the system.tag.exists function, as follows:

 ![ig_tagexists](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/5f2557d56608a8023ce0b9d611ebb3e6133acf64.jpeg)

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [June 24, 2019, 2:53pm UTC](https://forum.inductiveautomation.com/t/system-tag-read-not-returning-a-value/23892/4 "2019-06-24T14:53:36Z")

</div>

I’ll need to look into the final four entries in the result table, because an invalid tag path should never result in a True result, although every other result looks exactly as I’d expect.

A couple of things to remember which could be the source of your belief that some results are unexpected:

1. Python uses the following conditions to determine truth: [https://docs.python.org/2/library/stdtypes.html#truth](https://docs.python.org/2/library/stdtypes.html#truth) Since a QualifiedValue is an Object, a QualifiedValue is to be considered True. SO even though the returned QualifiedValue has an attribute named “value” which is `False`, we are only checking the object - not the attached attribute.
2. The Script Error entries are expected, because there is no attribute with a key of “Value”; case matters in python (and almost every other scripting language).

Additionally:  
The “value” of the QualifiedValue is an _attribute_, **not** a _parameter_. It might sound nit-picky, but there is a very big difference, and you could easily confuse a lot of people who are not paying attention to what you’re asking.

Parameters are pieces of information (values) which are used to build objects (classes, methods, tags, etc.). These parameters are important during the creation phase, even if they’re not used at creation. If you are “passing” a value, then that value is a parameter.

Attributes are values that something has. Your vehicle has a license plate number which is an attribute of that vehicle, but it is not a parameter. If you are reading/obtaining/getting a value _from_ an object, then that value is an attribute.

---

<div class="post-metadata">

**Author:** ![pdixon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pdixon/32/6899_2.png) [@pdixon](https://forum.inductiveautomation.com/u/pdixon)\
**Post date:** [June 24, 2019, 3:35pm UTC](https://forum.inductiveautomation.com/t/system-tag-read-not-returning-a-value/23892/5 "2019-06-24T15:35:52Z")

</div>

Thanks on the clarification of attributes and parameters. In a lot of control systems, parameters are attributes of a tag.

I updated the table, but the result is the same; if the “.value” is not specified the result is always True. Below is the script I used with invalid tag TestBool55 and no “.value” reference:

 ![ig_tagexists_01](https://us1.discourse-cdn.com/inductiveautomation/original/2X/0/09d4241253fb26127c5ef8b40d4243232b63ef39.jpeg)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 24, 2019, 3:41pm UTC](https://forum.inductiveautomation.com/t/system-tag-read-not-returning-a-value/23892/6 "2019-06-24T15:41:40Z")

</div>

> [@pdixon](#):
>
> I updated the table, but the result is the same; if the “.value” is not specified the result is always True. Below is the script I used with invalid tag TestBool55 and no “.value” reference:

Yes, that's exactly what @cmallonee was saying. `system.tag.read()` returns an object - Python will **always** evaluate an object as a `True` value. The actual Python/Jython interpreter doesn't have any idea what a `QualifiedValue` is; it doesn't know that it should "care" about the `.value` attribute. You _have_ to use the `.value` attribute to get an actual _primitive_ value (ie, number, boolean, string) if you want evaluation to work correctly.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [June 24, 2019, 3:45pm UTC](https://forum.inductiveautomation.com/t/system-tag-read-not-returning-a-value/23892/7 "2019-06-24T15:45:46Z")

</div>

Ah, yes, what @paul-griffith said makes sense (I was just getting to testing it).

In the event you provide an invalid tag path, you would still receive a QualifiedValue, but it would have a `value` of `None/null`, and a “bad” `quality` (probably “not\_found”). so even though the QualifiedValue is informing you that no tag exists on the provided path, your ARE still getting an object returned to you, and that object would equate to `True`.

---

<div class="post-metadata">

**Author:** ![ematschke](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ematschke/32/7544_2.png) [@ematschke](https://forum.inductiveautomation.com/u/ematschke)\
**Post date:** [July 18, 2019, 9:54pm UTC](https://forum.inductiveautomation.com/t/system-tag-read-not-returning-a-value/23892/8 "2019-07-18T21:54:58Z")

</div>

you provide a link to the help for system.tag.read that should be helpful, but that help topic does not show the syntax you describe.  
How am i supposed to know this?  
Is the syntax described above the correct way? if so then it should be in the help.  
The help is often not helpful unless one is already well versed in Ignition and Python, but the reason we go to help is because we need help.

---

<div class="post-metadata">

**Author:** ![ematschke](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ematschke/32/7544_2.png) [@ematschke](https://forum.inductiveautomation.com/u/ematschke)\
**Post date:** [July 18, 2019, 9:56pm UTC](https://forum.inductiveautomation.com/t/system-tag-read-not-returning-a-value/23892/9 "2019-07-18T21:56:54Z")

</div>

Then why doesn’t the help topic tell me that?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 18, 2019, 10:58pm UTC](https://forum.inductiveautomation.com/t/system-tag-read-not-returning-a-value/23892/10 "2019-07-18T22:58:35Z")

</div>

Our documentation is always improving. It’s hard to reach everyone - you can’t explain the same concepts fundamentally on every single page. I just worked with training so that the `system.tag.read` page in the 7.9 manual, and the 8.0 equivalents (readBlocking, readAsync) are updated, and have links to a new glossary entry on QualifiedValue objects.

For more fundamentals, there’s the more in-depth [reading and writing to tags](https://docs.inductiveautomation.com/display/DOC79/Reading+and+Writing+to+Tags) page - the appendix reference @MMaynard linked is _generally_ geared toward more familiar users who just need a quick reference.

---

<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 18, 2019, 11:23pm UTC](https://forum.inductiveautomation.com/t/system-tag-read-not-returning-a-value/23892/11 "2019-07-18T23:23:36Z")

</div>

Another great resource is the Inductive University.  
It is FREE and takes you through the basics right into more advanced topics.

[https://www.inductiveuniversity.com/](https://www.inductiveuniversity.com/)
