Quote:
Originally Posted by ownedbycats
Code:
program:
subjects = $#subjects;
admintags = $#admintags;
existing_colls = $#kobocoll;
new_colls = strcat(
if $#booktype=='Fanfiction' then 'Fanfiction,' fi,
if '^Cozy Mystery$' inlist subjects then 'Cozy Mysteries,' fi,
if '^Horses$' inlist subjects then 'Horses,' fi,
if '(Juvenile|Young Adult)' inlist subjects then 'Juvenile & Young Adults,' fi,
if '^(Fantasy|Paranormal|Science Fiction)$' inlist subjects && !'Star Trek' inlist subjects then 'Fantasy & Sci-Fi,' fi,
if '^Star Trek$' inlist subjects then 'Star Trek,' fi,
if 'Omnibus' in admintags then 'Omnibuses' fi,
);
Line 12, can be done without the extra inlist?
|
Yes, it can be done but it is complicated and probably slower. It would be some combination of list_intersection and list_count. It could be done as a python template used as a function, something like
Code:
check_inlist_field(field, values required, values_not_allowed)
but I don't see a pressing need here.
You should use "inlist_field '#subjects'" instead of "inlist subjects".
I also suggest you use parentheses on line 12 to avoid any possibility of operator precidence being what you don't want. Example:
Code:
if ('^(Fantasy|Paranormal|Science Fiction)$' inlist_field '#subjects') && (!('Star Trek' inlist_field '#subjects')) then 'Fantasy & Sci-Fi,' fi,