not returning a value?

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?

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


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:

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

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: 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).

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.

1 Like

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:

Yes, that’s exactly what @cmallonee was saying. 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.


Ah, yes, what @PGriffith 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.

you provide a link to the help for 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.

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

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 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 page - the appendix reference @MMaynard linked is generally geared toward more familiar users who just need a quick reference.

1 Like

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