Quote:
Originally Posted by ackomb
[...]
But it only works now if it only contains show A and show B in that specific order. But as soon as there is a Show C, which is not interfering with the pairing it does not work anymore.
That means the first if statment should be something like:
Code:
if $#show contains item "show A" and "Show B" then
Of course this does not work but how would, so I tried:
Code:
if $#show != "Show A" && "Show B" then
This seems to work. Just thought I would post it for others researching something similar.
|
The "seems to work" statement doesn't do what I think you want. It first asks if $#show isn't equal to the single item "Show A", which in the case of the list 'Show A, Show B' is True. It then 'ands' that True with the value 'Show B', which is always True. As such the expression will return True even if $#show contains 'foobar'.
Are you looking for code that tells you if both "Show A" and "Show B" are in the list, perhaps along with other values such as "Show C"? If so and if you can guarantee that there are no duplicates in the list then this works.
Code:
program:
show = list_count_matching($#show, '^(Show A|Show B)$', ',') == 2
output = '';
for item in $#pair:
if show then
if item == "ABC/XYZ" then ni = "AAA / BBB"
elif item == "DEF/UVW" then ni = "CCC / DDD"
else ni = item
fi
else ni = item
fi;
output = output & ',' & ni
rof;
output = list_sort(list_remove_duplicates(output, ','), 0, ',')
This version is more robust in the face of duplicates but is a bit slower.
Code:
program:
show = list_count(list_intersection($#show, 'Show A, Show B', ','), ',') == 2
[code as above]