Ignition Expression Tag - Switch Expression Function

Experts!

I need your help in understanding why I can't have multiple cases for one result.

https://docs.inductiveautomation.com/display/DOC81/switch

This documentation shows how I can use the switch statement, so for one of the tag, I'm trying to create an expression tag that looks like this:

switch({[default]RFID_Trial/Department},
{[default]RFID_Trial/Department_list[7,0]} || {[default]RFID_Trial/Department_list[8,0]},
"Engineering",
"Unauthenticated")

Is this just the limitation of the Ignition itself, or am I having a wrong syntax?

Your help is much appreciated, thank you!

That's equivalent to,

If({[default]RFID_Trial/Department} =
    {[default]RFID_Trial/Department_list[7,0]} || 
    {[default]RFID_Trial/Department_list[8,0]},
    "Engineering",.     // if true.
    "Unauthenticated".  // if false
)

Is this what you really want?

The case syntax is easier to read than switch.
https://docs.inductiveautomation.com/display/DOC81/case

Probably best to use case and this:

case({[default]RFID_Trial/Department},
     {[default]RFID_Trial/Department_list[7,0]}, "Engineering",
     {[default]RFID_Trial/Department_list[8,0]}, "Engineering",
     "Unauthenticated")
1 Like

Thank you,

But I do want to avoid the use of If-Elseif-else logic in my application for this one, because there's going to be 10 result outcomes I need, with each result having 2-10 conditions for each result.

It could end up getting into a nested ifs also.

On second thought... I think it would still look ugly with case :frowning:
I'll stick with if statements.

Just to finish the explanation: "OR" in expressions is either logical or bitwise--it never assembles a list of values for another operator to act upon. (This is true in python, too.)