# List Contains Test

This function tests if a list in a field or named variable, with a specified delimiter, has an item equalling, containing, starting with or ending with specified data.

The comparison operation may be performed case insensitive and/or diacritic insensitive.

If the trimmed option is set, leading spaces in the lists and in the match against data fields will be ignored at runtime.

All text fields may contain any of the escape sequences described in Escape Sequences. All fields are reevaluated whenever appropriate.

The action test state is set to true if a matching item is found, otherwise false.

If the Remove option is specified, the first matched item will be removed from the list.

If trimmed is specified the new list will have the trimmed values.

If the Save index to option is specified, the index of the first matched item will be saved to the specified track or named variable. Note the result will be set to empty if no match is made. If you also specify the Save all indexes option, all matching indexes will be saved as opposed to only the first. The saved value is a list using the default list delimiter (\~) to separate the indexes. Note that when Remove is enabled, the returned index or indexes reflect the original indexes before the items were removed.

If the Save item to option is specified, the matched item will be saved to the specified track or named variable. Note the result will be set to empty if no match is made. This is typically only useful when testing if the data is contained.

If the delimiter resolves to be empty when the action is executed, a default (\~) will be assumed.

Note that when running stepwise there are some special considerations:

- When searching through a list in a named variable the operation is only performed once unless the per file test option is set.
- The action test state is set to true if the item was contained in any of the files.

Example: Assume the Artist field contains a list of artists separated by commas. You want to ensure that the Album Artist, if present in the list always comes first. Further, you want to ensure that every comma is followed by a space. The following action will implement the desired functionality:

Test if the list in field Artist delimiter "," has an item equalling case and diacritic insensitive trimmed "\[Album Artist]", remove, item->V0
Test if the Variable 0 field is not empty (Set result and Variable 1)
Ignore files where Variable 1 is false
if true
Add "\[Album Artist]" to the start of the list in field Artist delimiter ","
Build List with delimiter ", " in field Artist from field Artist (As found) (case and diacritic insensitive) string delimiter ",", grouped
Restore Initial Set of Files
endif