View Single Post
Old 05-15-2014, 08:13 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)
Instead of
Code:
{#fandom:'test($, $, field('authors'))'}
use

Code:
{#fandom:'
	ifempty(
		sublist($, 0, 1, ","),
		field("authors")
	)
'}
which should use sublist to return the zeroth through first items in #fandom, assuming they are separated by "," and ifempty, returning the authors field instead.

EDIT: This code block takes up several lines, but only because I wanted to make it clear what is going on -- I like to indent and put each section on its own line. It may actually be MORE readable in calibre if it is all one line; this works too:
Code:
{#fandom:'ifempty(sublist($, 0, 1, ","), field("authors"))'}

Last edited by eschwartz; 05-15-2014 at 08:17 PM.
eschwartz is offline   Reply With Quote