How to tell if a tag exists

How can I tell if a tag exists programmatically?

I have a few different versions of a data structure in use in one of my PLCs and wanted to use one faceplate. Some of the versions have additional tags so I wanted to test for the presence of these and display/hide the related numeric displays (rather than have them show up with the broken tag link)

Cheers

Alex

Tags will always have quality even if they don’t exist. You can check for good quality (192) to determine your displays. Also, there should be a checkbox in the binding dialog to not have a quality overlay for that binding.

Yeah, we should really have a tagExists expression function that returns 0 or 1 and never errors out. I will add a ticket into our system.

As gbuehler suggested, you might be able to bind your visible property to an expression that checks the tag quality. Instead of just looking for good quality, you should be able to look specifically for “not found”, which is value 404 (funny, I know).

Regards,

[quote=“Colby.Clegg”]As gbuehler suggested, you might be able to bind your visible property to an expression that checks the tag quality. Instead of just looking for good quality, you should be able to look specifically for “not found”, which is value 404 (funny, I know).

Regards,[/quote]

Just to expand on this a bit more, check pages 9 and 10 of the Custom Driver Whitepaper for all the quality values.

[quote=“Colby.Clegg”]Instead of just looking for good quality, you should be able to look specifically for “not found”, which is value 404 (funny, I know).
[/quote]
:laughing:

sorry Bobby, 998 more posts to (not) go

Thanks for the help! Worked like a charm

hmm,

I get 300, Config Error, when I query the quality of a non-existing SQLTag.
Ver 7.2.10

Yeah, we should really have a tagExists expression function that returns 0 or 1 and never errors out. I will add a ticket into our system.

Is this still not available?

No, there is this TagPathParser.parseSafe function that only parses a list of tags ignoring those which are not found, without giving any exception if anyone’s aren’t. I was expecting this to give an exception for not found tags or have a function to test existence of a tag. Perhaps its something to do with efficiency, in a single function call you get both the path and the status (404 if not found) of tags.

There is actually a workaround. You can use the runScript expression function to use our system.tag.exists scripting function like this:

runScript("system.tag.exists", 0, "Refrigeration/ambientTemp")

1 Like