This is actually a simple problem… You are doing the $set()
operations outside of the $if()
functions, so they are always being executed.
Also, there is a problem with some of your tests. You are testing %_primaryreleasetype%
in each of the tests, but it will only contain one value from the list: “album”, “single”, “ep”, “broadcast” and “other”. Testing for “live” and “soundtrack” will always fail.
The variable %_secondaryreleasetype%
can contain zero or more items from the list: “audio drama”, “audiobook”, “compilation”, “demo”, “dj-mix”, “interview”, “live”, “mixtape/street”, “remix”, “soundtrack” and “spokenword”.
Because you are testing for items that could be contained in both %_primaryreleasetype%
and %_secondaryreleasetype%
, you might be better off testing against the %releasetype%
tag, which contains the items from both the %_primaryreleasetype%
and %_secondaryreleasetype%
variables.
Perhaps something like:
$if($in(%releasetype%,single),$set(TESTTHIS,Single))
$if($in(%releasetype%,live),$set(TESTTHIS,Live Performance))
$if($in(%releasetype%,ep),$set(TESTTHIS,EP))
$if($in(%releasetype%,soundtrack),$set(TESTTHIS,Soundtrack))
$if($in(%releasetype%,other),$set(TESTTHIS,Sound Effects))
Note that this will only retain the setting from the latest match. If you only want one match saved, then you would do your tests in the order from least preferred (first) to most preferred (last).
If you want to match and keep more than one setting, I would do something like:
$if($in(%releasetype%,single),$set(TESTTHIS,%TESTTHIS%; Single))
$if($in(%releasetype%,live),$set(TESTTHIS,%TESTTHIS%; Live Performance))
$if($in(%releasetype%,ep),$set(TESTTHIS,%TESTTHIS%; EP))
$if($in(%releasetype%,soundtrack),$set(TESTTHIS,%TESTTHIS%; Soundtrack))
$if($in(%releasetype%,other),$set(TESTTHIS,%TESTTHIS%; Sound Effects))
$set(TESTTHIS,$trim(%TESTTHIS%,; ))
This would keep adding each match to the %TESTTHIS%
tag, separating the items with a semicolon and space. The final line trims off the extra semicolon and space that would appear at the beginning of the combined %TESTTHIS%
tag.
EDIT:
If I were doing something like this for myself, I would probably set the separator in a variable. That way, if I changed my mind as to what I wanted to use to separate the choices I would only need to make the change in one place rather than in every $set()
statement. Something like:
$set(_separator,; )
$if($in(%releasetype%,single),$set(TESTTHIS,%TESTTHIS%%_separator%Single))
$if($in(%releasetype%,live),$set(TESTTHIS,%TESTTHIS%%_separator%Live Performance))
$if($in(%releasetype%,ep),$set(TESTTHIS,%TESTTHIS%%_separator%EP))
$if($in(%releasetype%,soundtrack),$set(TESTTHIS,%TESTTHIS%%_separator%Soundtrack))
$if($in(%releasetype%,other),$set(TESTTHIS,%TESTTHIS%%_separator%Sound Effects))
$set(TESTTHIS,$trim(%TESTTHIS%,%_separator%))