Universal symbol

Hi everyone! I am very grateful for the help I was given before! But I came to the dead end again. Can anyone tell me if there is a universal character like “*” in “Expression” that can replace any meaning or word?

The ‘like’ operator can use ‘%’ and ‘?’ wildcards.

https://docs.inductiveautomation.com/display/DOC80/Expression+Overview+and+Syntax#ExpressionOverviewandSyntax-Operators

tag (like (%) + “/ HMI / Alarm / Jammed.value”) = true
Where Like (%) should go through the entire tag base, and if at least 1 is true, then change the color.
How i can write it?? or use

I’m going to channel my inner @pturmel and say even if this works, it seems like an extraordinarily bad idea.

There has to be a better way. What exactly are you trying to accomplish?

1 Like

Well, safe to say, that an expression is not really what you need. You would need to script this.

def browseTags(path, filter):
  
    # First, browse for anything that can have children (Folders and UDTs, generally)
    results = system.tag.browse(path)
    for branch in results.getResults():    
        if branch['hasChildren']:
            # If something has a child node, then call this function again so we can search deeper.
            # Include the filter, so newer instances of this call will have the same filter.
            browseTags(branch['fullPath'], filter)
 
     
    # Call this function again at the current path, but apply the filter.
    results = system.tag.browse(path, filter)
    for result in results.getResults():
         
        # Here's where you'd want to do something more useful. For now we print.
        print result['fullPath']
        tagList.append(result['fullPath'])
          
# Call the function. Replace the filter with your own search criteria.
tagList = []

browseTags('[default]', {'name':'*/HMI/Alarm/Jammed'})

tagValues = [tag.value for tag in system.tag.readBlocking(tagList)]

anyValue = any(tagValues)

system.tagWriteBlocking(['path/to/tag'],[anyValue]) 
1 Like


Basically I want to create a indicator that will light up when {Root Container.Button for Footer 2.Area}={default/HMI/Alarm/Jammed.Area} && {default/HMI/Alarm/Jammed.value}
I think that the best way to do so, it is as in my screenshot, but I don’t know how to replace highlighted bunch of symbols to %%(any symbols)
maybe someone knows better way to solve this problem

You can’t. Property and tag references via curly braces return one tag or property value. There’s no syntax to return multiple. You would need to script a loop that searches through the tags. Exceedingly inefficient, too.

1 Like

which method can be effective?

I should use your script in scripting my indicator?

Where are you take def…( path…) because i see only def… (self…)?

I would recommend creating an expression tag. In the expression tag, or the values of the tags you are interested in.

Then bind to that tag.

I would run it in a gateway timer script.

Performance will get slower, the more tags you add to your gateway, though. Consider two separate scripts, one to browse and keep track of the tag names at a fairly slow rate, and one to read the values.


The suggestion of an expression tag is a good one, but may be more difficult to maintain if things get added or subtracted.

I don’t want to write down all the tags I need, I want to automate it! But, alas, I don’t know how ((((

if these tags are in the database, since they are alarms, it might be easier to get their value from there?

If you’re doing at as an indicator, it would be better to get it from the tags.

that is, will I have to write many tags in expression? and you can’t make it universal?

I understand and approve of the sentiment, but you should only automate at runtime if the list can change at runtime. Tag browsing is slow and expensive–you should only do it to set up a calculation, not every time you wish to run it. I recommend caching a tag browse result in a project script top-level variable that you can reference from other code.

3 Likes

I don’t know how I can do it, maybe you can tell me?

Maybe. Does your list of tags change at runtime? And how many are there?

in the end, their number will not change