How to detect a null value in a string tag

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.

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

1 Like

Thanks, I will try that..

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,,,

Opps, forgot the :

Works as you expected. Thanks

Please see Wiki - how to post code on this forum.

1 Like