View Single Post
Old 06-25-2014, 09:26 AM   #12
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,336
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by myki View Post
Thank you very much, it is very instructive !
...
Code:
#author_sort_lastname with {:'uppercase('{author_sort:list_item(0,\,)}')'}
And my save as modele :
Code:
{#author_sort_lastname} {#author_sort_firstname:re([.],)}/{series:'test($,'{series}/[{series}-{series_index:0>2s}] ','{#author_sort_lastname} {#author_sort_firstname} - ')'}{title}
I note that you are using subtemplates (nested templates). You should not do that. There are several ways that evaluating templates can break by using subtemplates.

Your first template is better written as something like
Code:
{author_sort:'uppercase(list_item($, 0,\,))'}
and your second one should really be written in general program mode because of its complexity, something like:
Code:
program:
	as = field('author_sort');
# list item removes the comma. Note that this doesn't work if there 
# are multiple authors or if the author name doesn't contain a comma
	asfn = list_item(as, 1, ',');
	asln = uppercase(list_item(as, 0, ','));

# Use the template function as a convenience to avoid calling format_number
	has_series = template('{series}/[{series}-{series_index:0>2s}]');
	no_series = strcat(asln, ' ', asfn, '  -');
	series_val = test(field('series'), has_series, no_series);

	strcat(asln, ' ', asfn,  '/', series_val, ' ', field('title'))
Note that this template does not make use of the #author_sort_*_name columns, so perhaps they can go away.
chaley is offline   Reply With Quote