Expression for Value in Array

Hi,

After the dropdown bi-directional binding to array tags have been fixed, I want to test if something is in the selected array.

As a test I have a dropdown where days of the week are selected. I want to make an expression tag to check if today (getDayOfWeek(now())) is in that array, but I can’t seem to find the equivalent of the Python in. See example below:

Is there an expression I can use? I don’t really want to resort to runScript()

Thanks,
Deon

Can you create a change script on value (on the dropdown) then push this where you want?

Starting in 8.1.8 (releasing very soon), you'll be able to use indexOf() on the array for this; it'll return -1 if the target value is not found.
Unfortunately, in the meantime I think runScript is your best bet.

Excellent. I can wait for 8.1.8.

I saw the indexOf(), but for the time being the documentation only refers to string. Will use when upgrading.

In case this helps others...

The current description in the v8.1 user manual entry for indexOf() makes no mention of compatibility with lists.

Description

Searches for the first occurrence of the substring inside of string. Returns the index of where substring was found, or -1 if it wasn't found. The first position in the string is position 0.

However, in the Syntax section there is a note for version 8.1.8, stating compatibility with "tuples and lists". It is easy to overlook if you are just scanning descriptions... as I was.

This feature was changed in Ignition version 8.1.8:

The object parameter now accepts tuples and lists.

2 Likes