Expression tag PLC reference

You could also convert them to case | Ignition User Manual statements which are a bit easier to read.

case(
    {[.]Line},
    "LineA", 1,
    "LineB", 2,
    "LineC", 3,
    "LineD", 4,
    "-"
)

Note that the original expression is inconsistent. In one case it returns a string, "-" and in all the others it returns an integer. This is likely to cause problems elsewhere. (My expression does the same as it's merely a conversion from switch to case.)

Tip: for future code questions, please see Wiki - how to post code on this forum.

1 Like