System.tag.exists in expression error

Hi,

I have been trying to use runScript("system.tag.exists", 0, {tag_Path}) and I am seeing something weird. If the path doesn't exist the expression returns False, however, if the tag does exist then I get an error,

Any suggestions on what is going on? User error?

Can you post the script of system.tag.exists? (Format it using the </> button.)

I'm not sure. Where do the system scripts live?

Oops! It's getting close to bedtime here. I didn't recognise it as a built in function. I thought it was something you wrote. Carry on ...

you could probably also do this

try(
	isGood({[.]tagPath}),
	False
)

I don't think you want the {} in the expression, as the argument you are passing is supposed to be a string representing a possible tag path, as opposed to the value of an actual tag.

runScript("system.tag.exists",0,"path/to/tag")

I believe you are getting the error because the expression is trying to parse the tag path. When the path doesn't exist then it sends a value of "none", which incorrectly returns the correct value because the path "none" doesn't exist. When the path does exist, then it tries to send the value of the tag which probably can't be properly parsed to a valid path.

Personally, I would use the approach that @dkhayes117 showed, because then you don't have to pay the cost of starting up the interpreter.

Thanks, that was the issue. I was actually using relative paths from a property but had been using Tag() so it's the same idea. If I remove the Tag() then it appears to work like it should

My concern with isGood is that I have a bunch of radio based sites that can have enough delay to cause Bad statuses. Things would be blinking all over the place.

I'm not sure what the resource cost of the interpreter is but server wise I have a lot to work with.

If you are concerned with bad statuses, then you can use the isBad() or isBadOrError() expressions.

For posterity, I'll note that the system.tag.exists function is just doing a tag read of the .Name subproperty (because .Value can be expensive to read for some types of tags). So if you already have a path to a tag, qualityOf({that/tag/path.name}) != "Bad_NotFound" will give you the exact same result as system.tag.exists.

8 Likes

Or isAvailable() from Paul's Ignition Extensions module, which checks if the tag is both not disabled and exists, because those are the only two states in which you would want to hide something using, otherwise you would be masking a genuine issue. (to test for these two qualities without isAvailable is a horrible monster of an expression)

Still hoping that this makes it into the product!!!!

2 Likes

thanks. there is a lot of very cool, and pretty much required parts for my operators, that exists but hasn't made it into the product, Paul's extensions and the Ad-Hoc Trends and Rosters come to mind.