Tag syntax help

Need help in creating a tag that has this syntax
if (part_number = '32013-03',y_limit = 20,y_limit = 0)

So, expression tag? It would be something like this:

if({path/to/part_number}='32013-03', 20, 0)

Where the name of the tag would presumably be y_limit.

(Expressions cannot perform assignments internally--their result is assigned to a tag or to a bound property.)

part_number is an OPC string tag in my project so, my syntax for tag Y_limit below
If ( part_number = "32013-03",20,0 gives me an error_configuration...still missing something

The braces around the path to part number tag are required. The part I showed in my example that is between the braces is the only part of my example that isn't to be used verbatim.

I want this expression to return a value of 20, instead it returned a 0
if ({[Cast Iron]IC_grinding/Part_number} ='32013-03', 20, 0)

Looks like your part number has spaces. You either need to match them in the comparison or trim them in the source data.

Also, since the two tags are in the same folder, you can use the "same folder" provider notation to simplify your expression. Like so:

if({[.]Part_number}='32013-03', 20, 0)

Tag string spaces
I was about to say the same thing.

changed the length to 8 of the string tag in the plc and it worked fine....thanks for your help

odd question, how would the syntax look if I wanted to check the part_number against multiple values? If ({[.]part_number} ='32013-03'||'32013-02'||'32013-01',20,0)

    '32013-03', 20,
    '32013-02', 20,
    '32013-01', 20


1 Like

If you don't want to use case(), you'd need to spell out each comparison between the || operations. Or'ing the values is not a shortcut for or'ing the comparisons.

FWIW, I hate the fixed nature of case(). I tend to put the values in a dataset and use lookup().

I think I will set a bool in the HMI and just change Y_limit in Ignition. I will need only two tags to set the y-axis max limit