View Single Post
Old 09-30-2014, 06:09 AM   #4
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,476
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
OK, I understand. You want a template that returns something like "yes" (or in your case an icon file name) for a book if that book would match a particular search expression.

Although this is possible to do and probably isn't intellectually difficult, it would be very tedious. It would need to understand the search syntax in all its glory (regexps, ranges, etc) and be able to translate these into an equivalent template expression. As this isn't something I would ever use, I don't want to spend the many days to build it.

FYI and to give some idea of the complexity: the template for your example would be something like
Code:
program:
# pubdate:<=1922-1-1 and formats:"=PDF" and tags:"=Historical"
test(
	and(
		strcmp(
			format_date(raw_field('pubdate'), 'yyyy-MM-dd'), 
			'1922-01-01', 
			'y', 'y', ''),
		in_list(approximate_formats(), ',', 'pdf', 'y', ''),
		in_list(field('tags'), ',', '^Historical$', 'y', '')
	),
	'yes',
	'no')
This isn't hard for a human to work out, but the translating program would need to know things like when to use field lookup vs raw_field vs like approximate_formats, how to deal with dates, and when to use anchors on the match patterns.
chaley is offline   Reply With Quote