Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 04-10-2012, 10:44 AM   #1
razorsoup
Enthusiast
razorsoup began at the beginning.
 
razorsoup's Avatar
 
Posts: 33
Karma: 10
Join Date: Jan 2012
Location: Texas, USA
Device: Kindle Paperwhite 4
Help with series_sort()

I am trying to create a custom column that combines the series info with the title info in Calibre. What I currently have that column define as is
Code:
{series}{series_index:0>2s| [|]: }{title_sort}
and that is working as expected. But I would rather have the series portion use the library sort form rather than keep the articles(a, an, the) at the beginning. I tried
Code:
{series:series_sort()}{series_index:0>2s| [|]: }{title_sort}
but I get the following message:
Quote:
TEMPLATE ERROR evaluate() takes exactly 5 arguments (7 given)
What am I doing wrong?

Calibre version 0.8.46, Windows XP SP3

Edit: Also, is this the right board for this question or should I have posted somewhere else?

Last edited by razorsoup; 04-10-2012 at 10:49 AM. Reason: Question about board
razorsoup is offline   Reply With Quote
Old 04-10-2012, 11:14 AM   #2
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: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
The series_sort function can be used only in template program mode or general program mode. You are using single function mode.

In TPM you would use
Code:
{:'series_sort()'}{series_index:0>2s| [|]: }{title_sort}
In GPM you would use:
Code:
program: strcat(series_sort(), finish_formatting(field('series_index'), '0>2s', ' [', ']: '), field('title'))
or possibly
Code:
program: strcat(series_sort(), finish_formatting(field('series_index'), '05.2f', ' [', ']: '), field('title'))
which better handles fractional series indices.
chaley is offline   Reply With Quote
Advert
Old 04-10-2012, 11:40 AM   #3
razorsoup
Enthusiast
razorsoup began at the beginning.
 
razorsoup's Avatar
 
Posts: 33
Karma: 10
Join Date: Jan 2012
Location: Texas, USA
Device: Kindle Paperwhite 4
I used
Code:
program: strcat(series_sort(), finish_formatting(field('series_index'), '0>2s', ' [', ']: '), field('title_sort'))
and it works perfectly now. Is there any benefit or detriment to using TPM over GPM or vice versa?

Thank you chaley!
razorsoup is offline   Reply With Quote
Old 04-10-2012, 11:52 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: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by razorsoup View Post
Is there any benefit or detriment to using TPM over GPM or vice versa?
For many people, TPM templates are easier to write and read. GPM templates are much more expressive -- can be used to solve more complicated problems.

GPM templates will usually have much better performance when they are used in custom columns. Calibre compiles them to python and runs them as part of calibre itself, so the templates run between 20 and 50 times faster than the equivalent TPM template.

On the other hand, compilation takes some about of time, which for small libraries may exceed the template's total running time. But for small libraries template running time doesn't really matter, so this shouldn't be an issue.
chaley is offline   Reply With Quote
Old 04-10-2012, 12:06 PM   #5
razorsoup
Enthusiast
razorsoup began at the beginning.
 
razorsoup's Avatar
 
Posts: 33
Karma: 10
Join Date: Jan 2012
Location: Texas, USA
Device: Kindle Paperwhite 4
So generally, GPM=More flexibilty and faster execution but more difficult to write while TPM=Slower execution but easier to write.

Awesome. Thanks for the help.
razorsoup is offline   Reply With Quote
Advert
Reply

Tags
calibre 8.46, custom column, error message, series sort


Forum Jump


All times are GMT -4. The time now is 08:38 AM.


MobileRead.com is a privately owned, operated and funded community.