# Can't Evaluate Tag Value

**URL:** <https://forum.inductiveautomation.com/t/cant-evaluate-tag-value/10772>\
**Category:** Ignition\
**Created:** [November 11, 2015, 6:22pm UTC](https://forum.inductiveautomation.com/t/cant-evaluate-tag-value/10772 "2015-11-11T18:22:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keith.Britton](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@Keith.Britton](https://forum.inductiveautomation.com/u/Keith.Britton)\
**Post date:** [November 11, 2015, 6:22pm UTC](https://forum.inductiveautomation.com/t/cant-evaluate-tag-value/10772/1 "2015-11-11T18:22:59Z")

</div>

Not sure what is happening here. All I want to do is test a tag value using a gateway script. I can’t seem to get consistent results. tagTest is a boolean, BTW:

[code]tagTest = system.tag.read(“Junk/MyTags/tag1234”).value

if (tagTest) :  
do\_something\_amazing()  
elif not (tagTest) :  
do\_something\_mediocre()  
[/code]

I’m seeing that the not true portion evaluates but not the true portion. I can set the tag manually and then run the script. One weirdness is I have Ignition 7.6.4 and I’m using Java 8 (because other software tools on my laptop require v8). I get some weird console/client errors when I open and close windows but I figure that’s because the versions of Java and Ignition are not getting along. I could definitely downgrade to Java v7 but was just wondering if this is a known thing or just the usual crop circles/satanic portal/bad programming from the general location of my cubicle.

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [November 11, 2015, 7:19pm UTC](https://forum.inductiveautomation.com/t/cant-evaluate-tag-value/10772/2 "2015-11-11T19:19:38Z")

</div>

First check your tag read results.

`tagTest = system.tag.read("Junk/MyTags/tag1234")
print tagTest.quality
print tagTest.value
print type(tagTest)`

That might provide some insight. Perhaps the tag read is not getting the value you expect?

Also you don’t need the parenthesis. This should work just as well:

`if tagTest.value:
    do_something_amazing()
else:
    do_something_mediocre()`

Edit: Should have been

```auto
print type(tagTest.value)
```

instead of

```auto
print type(tagTest)
```

---

<div class="post-metadata">

**Author:** ![Keith.Britton](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@Keith.Britton](https://forum.inductiveautomation.com/u/Keith.Britton)\
**Post date:** [November 13, 2015, 12:31pm UTC](https://forum.inductiveautomation.com/t/cant-evaluate-tag-value/10772/3 "2015-11-13T12:31:26Z")

</div>

I found a workaround: I used an expression tag to evaluate the tag that won’t cooperate and then I used my script to test the value of the expression tag.

Okay, I have a theory as to why this won’t work. Said “bad” tag is a custom data instance (“BI”). When I see the attributes for this type of tag it is indeed called out as a Boolean but its values are shown as “On” and “Off”. Maybe that’s why this test `if (system.tag.read("Junk/MyTags/badTag").value == True) :` doesn’t woik. Maybe the expression tag is converting the value to boolean so that the spice can flow.
