# How to detect a null value in a string tag

**URL:** <https://forum.inductiveautomation.com/t/how-to-detect-a-null-value-in-a-string-tag/99947>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [December 17, 2024, 6:00pm UTC](https://forum.inductiveautomation.com/t/how-to-detect-a-null-value-in-a-string-tag/99947 "2024-12-17T18:00:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Reed](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@Robert\_Reed](https://forum.inductiveautomation.com/u/Robert_Reed)\
**Post date:** [December 17, 2024, 6:00pm UTC](https://forum.inductiveautomation.com/t/how-to-detect-a-null-value-in-a-string-tag/99947/1 "2024-12-17T18:00:49Z")

</div>

If my tag reads come back with a null string, example coming from a db query that found no record, the script errors out.

I have tried using len(x) to try to find a zero length string but it also errored out.

---

<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:** [December 17, 2024, 6:01pm UTC](https://forum.inductiveautomation.com/t/how-to-detect-a-null-value-in-a-string-tag/99947/2 "2024-12-17T18:01:46Z")

</div>

Idiomatic Python null checking is `if x is None` or `if x is not None`.

---

<div class="post-metadata">

**Author:** ![Robert\_Reed](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@Robert\_Reed](https://forum.inductiveautomation.com/u/Robert_Reed)\
**Post date:** [December 17, 2024, 6:02pm UTC](https://forum.inductiveautomation.com/t/how-to-detect-a-null-value-in-a-string-tag/99947/3 "2024-12-17T18:02:35Z")

</div>

Thanks, I will try that..

---

<div class="post-metadata">

**Author:** ![Robert\_Reed](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@Robert\_Reed](https://forum.inductiveautomation.com/u/Robert_Reed)\
**Post date:** [December 17, 2024, 6:04pm UTC](https://forum.inductiveautomation.com/t/how-to-detect-a-null-value-in-a-string-tag/99947/4 "2024-12-17T18:04:49Z")

</div>

i tried  
NullResultCheckFromDB = system.tag.read("[default]DB/WI\_Query/CrossMember/110\_InstMsg\_1stHalf").value

if NullResultCheckFromDB is None  
print 'Error-GWScript-WIQueryDB\_UpdateTags\_Crossmember Null return'

but it won't accept it due to compile error,,,

---

<div class="post-metadata">

**Author:** ![Robert\_Reed](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@Robert\_Reed](https://forum.inductiveautomation.com/u/Robert_Reed)\
**Post date:** [December 17, 2024, 6:05pm UTC](https://forum.inductiveautomation.com/t/how-to-detect-a-null-value-in-a-string-tag/99947/5 "2024-12-17T18:05:35Z")

</div>

Opps, forgot the :

---

<div class="post-metadata">

**Author:** ![Robert\_Reed](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@Robert\_Reed](https://forum.inductiveautomation.com/u/Robert_Reed)\
**Post date:** [December 17, 2024, 6:08pm UTC](https://forum.inductiveautomation.com/t/how-to-detect-a-null-value-in-a-string-tag/99947/6 "2024-12-17T18:08:10Z")

</div>

Works as you expected. Thanks

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 17, 2024, 6:08pm UTC](https://forum.inductiveautomation.com/t/how-to-detect-a-null-value-in-a-string-tag/99947/7 "2024-12-17T18:08:11Z")

</div>

Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).
