View Single Post
Old 09-25-2015, 03:54 PM   #697
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)
Try this. It uses the General Program Mode, which is a bit more flexible:

Code:
program:

# Candidate template for non-fanfiction books
reg_title = strcat(
	field('title'),
	finish_formatting(
		field('series_index'),
		'0>2s',
		' -',
		'- '
	)
);

# Candidate template for fanfiction books
fanfic_title = strcat(
	field('title'),
	' (',
	field('#chapters'),
	'ch, ',
	field('#words'),
	') ',
	field('#status'),
	' ',
	format_date(
		field('#updated'),
		'M-d-yy'
	)
);

final_title = strcmp(
	field('series'),
	'Fanfiction',
	reg_title,
	fanfic_title,
	reg_title
);
Basically, calculate the two templates, and check the value of series to see if it matches (case-insensitive) "fanfction". Then return whichever template is appropriate.
The last function is the return function, so final_title is the return value of the template.


This looks a little bigger than it really is because I prefer whitespace for readability.

Last edited by eschwartz; 09-25-2015 at 03:57 PM.
eschwartz is offline   Reply With Quote