![]() |
#1 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: May 2015
Location: Barcelona
Device: Cool-er
|
![]()
Good Morning.
When I send to disk (or device), I need to change the name: - If contains many authors, only select first: > authors:sublist(0,1,&) - Select the surname of author (last word): > authors:sublist(-1,0, ) Both sentences works fine, but I dont know how to combine them. My Save Template is: {authors:sublist(0,1,&)} - {series:|| }{series_index:0>2s|[|] - }{title} ({pubdate:sublist(-1,0,\,)}) AUTOR (only first) - SERIE [n] (if exists) - TITLE (YEAR) ![]() Thanks!! |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,445
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
You must use either general program mode (GPL) or template program mode. Which you choose depends on where the complexity is. In your case, determining in the template that there is more than one author might be a challenge, which would push me to GPL.
Here is a guess about what you might want expressed in GPL. Code:
program: a=field('author'); first_author = sublist(a, 0, 1, '&'); last_author=cmp(count(a, '&'), 1, '', '', strcat(' / ', sublist(a, -1, 0, '&'))); authors = strcat(first_author, last_author); rest = template('{series:|| }{series_index:0>2s|[|] - }{title} ({pubdate:sublist(-1,0,\,)})'); strcat(authors, ' - ',rest) |
![]() |
![]() |
![]() |
#3 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,065
Karma: 858115
Join Date: Jan 2011
Device: Kobo Clara, Kindle Paperwhite 10
|
I use this for sending to device: {author_sort:sublist(0,1,&)}
That lists the first or only author in author_sort whether there are more than one or not. The lastname is listed first in author_sort. For me distinguishing between one or two or three or too many (authors in author_sort) is too much trouble for not absolutely important information on the device. But I keep only a few books on device at a time. For saving to disk, I use {authors} which I have as firstname lastname Last edited by unboggling; 06-10-2015 at 11:08 PM. |
![]() |
![]() |
![]() |
#4 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: May 2015
Location: Barcelona
Device: Cool-er
|
Thanks chaley and unboggling.
I try how chaley says. ![]() I will respond if I have success... or not ![]() I dont understand your code yet, but maybe I not explain correctly: I need ONLY ONE AUTHOR AND ONLY HIS/HER SURNAME. Chaley, your code make this? (I try to undestand it) THANKS!! ![]() Last edited by davidam2; 06-11-2015 at 07:42 AM. |
![]() |
![]() |
![]() |
#5 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,445
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
If you want only the surname of the first author then we can probably use author_sort to get it easily. Something like the following in TPM Code:
{author_sort:'re($, '^([^,]*).*', '\1')'} - {series:|| }{series_index:0>2s|[|] - }{title} ({pubdate:sublist(-1,0,\,)}) |
|
![]() |
![]() |
![]() |
#6 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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)
|
chaley, I understood the OP to be asking about first author's lastname.
![]() Anyway, I would've used an author_sort sublist split on the "," -- it is more readable than a regex. No need for TPM. Last edited by eschwartz; 06-11-2015 at 11:54 AM. |
![]() |
![]() |
![]() |
#7 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,445
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
I used "re" because it has much higher performance than sublist, something that would matter if a similar template was used in a composite column. I also think that functions in single function mode are hard to read because of the lack of spacing. But of course, YMMV.
|
![]() |
![]() |
![]() |
#8 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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)
|
Well, obviously it is harder to read, but so is TPM. That is why I prefer GPM, but neither of us used that.
![]() (post #2 doesn't count) Good point about performance. |
![]() |
![]() |
![]() |
#9 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: May 2015
Location: Barcelona
Device: Cool-er
|
![]() ![]() Thanks Chaley!!! Thanks Eschwartz too! I don't know because I didnt think to use author_sort with a sublist split on the ",". I will use your regex code (higher performance). ![]() ![]() |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Nested Span? | Turtle91 | ePub | 4 | 05-20-2013 02:47 PM |
need help with nested template | Jade Aislin | Library Management | 2 | 11-30-2012 02:04 AM |
Nested headings? | crich70 | Sigil | 20 | 04-11-2011 10:44 AM |
Content Nested collections | fartang | Amazon Kindle | 1 | 04-09-2011 12:18 PM |
Are Nested TOCs Possible? | VikingDave | Sony Reader | 11 | 12-28-2007 07:58 PM |