I have a string array tag that contains an array of strings. I would like to use an expression to tell if a certain value is in this array. I tried using 'a' in {[.]list tag.value}, but that gives an error configuration. Is there a way to do this in expression language or some better way to tackle this problem?
indexOf(list, item)
should work for you. Your expression would be indexOf({yourList}, "item") != -1
for a boolean result.
in
is a Python operator, and has no meaning in Ignition's expression language:
I'm dealing with multiple values in an array so indexOf always returns -1:
I think I'm going to use script to do this.
What happens if you wrap the tag value in toList()
? Like indexOf(toList({arrayTagpath}), "item")
.
If you have the Integration Toolkit module you can try wrapping the tag value in asList()
. I believe in the background array tags are java arrays not lists, so the explicit type cast might get it into a format that indexOf
accepts.
Edit: Whoops, combined two things into something that doesn't exist in Ignition.
Where do get toList()
?
(Or do you mean the asList()
function from my Integration Toolkit?)
I think I was thinking of this while thinking of the default type casting options from Ignition. Somehow that got turned into toList
and I thought it came default. Whoops.
Turns out this does work and I had a typo in the string I was checking for.
Appreciate the help!