View Single Post
Old 04-29-2021, 04:58 AM   #84
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,063
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
program:
	g = field('#genres');
	k = field('#kobocoll');

	if list_contains(g, ',', '^Fanfiction$', '1', '') then
		k = list_union(k, 'Fanfiction', ',')
	fi;

	if list_contains(g, ',', '^Cozy Mystery$', '1', '') then
		k = list_union(k, 'Cozy Mysteries', ',')
	fi;

	if list_contains(g, ',', '^(Fantasy|Science Fiction)$', '1', '') then
		k = list_union(k, 'Fantasy & Sci-Fi', ',')
	fi;

	k
How would I run the first match it finds? For example, if I have a book with "Cozy Mystery" and "Fantasy" in g, I only want it to add Cozy Mysteries.

ownedbycats is offline   Reply With Quote