New question: I have an enumerated column, #purchasesource. Four of these have related identifiers that often are downloaded during metadata downloads:
Amazon - amazon
Baen - baen
Barnes & Noble - barnesnoble
Kobo - kobo
I prefer to have the identifier only for the store I got it from. So I made this template to remove the extra ones:
1. I have a book with #purchasesource set to "Kobo." After a metadata download, the book has goodreads, isbn, barnesnoble, and kobo identifiers.
2. Purchasesource
is not Barnes & Noble, so the second if-then removes the barnesnoble identifier.
3. Purchasesource
is Kobo, so the third if-then doesn't remove the Kobo identifier.
4. It doesn't remove the goodreads or isbn identifiers.
If I run the same template on a book that has
no #purchasesource, it removes all four of them. If no identifiers are removed, it just returns the original list.
Code:
program:
if
!$#purchasesource=="Amazon"
&& select($identifier, 'amazon')
then
list_difference ($identifier, strcat('amazon:', select($identifier, 'amazon')), ',')
elif
!$#purchasesource=="Barnes & Noble"
&& select($identifier, 'barnesnoble')
then
list_difference ($identifier, strcat('barnesnoble:', select($identifier, 'barnesnoble')), ',')
elif
!$#purchasesource=="Kobo"
&& select($identifier, 'kobo')
then
list_difference ($identifier, strcat('kobo:', select($identifier, 'kobo')), ',')
elif
!$#purchasesource=="Baen"
&& select($identifier, 'baen')
then
list_difference ($identifier, strcat('baen:', select($identifier, 'baen')), ',')
fi
As it's basically just running the same if-then with different values, is there a better way to do this?