View Single Post
Old 01-07-2023, 05:39 AM   #459
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,529
Karma: 8075938
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
That worked.

Tweaking my #kobopath template:

[...]

Based on that second disadvantage, I'm inclined to go with option #1. Does this make sense?

I would avoid complexity and make the checks explicit. The new switch_if() makes it easy and compact to do the checks in order. Something like this:
Code:
program:

# Returns 'Fanfiction/Fandom' tag for fanfics
	booktype = 'Fanfiction';
	tags = 'Fanfiction.Bar, Fanfiction.Crossover, Fanfiction.Foo';
	if booktype == 'Fanfiction' then
		switch_if(
			'^Fanfiction\.Crossover$' inlist tags, 'Fanfiction/Crossover',
# More tests in the order you want
			'^Fanfiction\.Foo$' inlist tags, 'Fanfiction/Foo',
#			...
# If none of the tests find a value then end up picking the first one. 
# If the list is empty then this will return the empty string.
# You only need the list_re() if the list can contain values other than
# Fanfiction.XXX.
			list_item(list_re(tags, ',', '^Fanfiction.(.*)$', 'Fanfiction/\1'), 0, ',')
		)
	fi
chaley is offline   Reply With Quote