View Single Post
Old 01-30-2014, 06:50 PM   #2
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
http://manual.calibre-ebook.com/temp...-not-found-val

Quote:
str_in_list(val, separator, string, found_val, not_found_val)
str_in_list(val, separator, string, found_val, not_found_val) – treat val as a list of items separated by separator, comparing the string against each value in the list. If the string matches a value, return found_val, otherwise return not_found_val. If the string contains separators, then it is also treated as a list and each value is checked.

use "," as separator, val will be field('tags') and you want to search for string "First", then return found_val "First". not_found_val should return empty "" which first_non_empty should skip over, I think.

Personally, I think you should use general program mode for this:

Code:
program:
	first_non_empty(
		str_in_list(
			field('tags'),
			",",
			"First",
			"First",
			""
		),
		field('series'),
		"Uncategorized"
	)
eschwartz is offline   Reply With Quote