View Single Post
Old 09-24-2021, 10:24 AM   #151
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,463
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by kevn57 View Post
This is a repost as I posted in the wrong thread

I'm a complete nube in calibre template language.

I'm trying to take the output of the plugin Pagecount which is the number of words in a book and dividing that by 320 which is my words per minute reading rate and output the total number of minutes to read the book into my custom integer col "#minutes"

I don't know how to assign the product of divide(vals, 320); to my custom column #minutes.

program:
col = '#pagecount';
vals = from_selection(col);
'#minutes' = divide(vals, 320);

But I get this result EXCEPTION: Formatter: Expected end of program, found '=' near '#minutes' on line 4
Where do you want to use the template? I ask because you are using from_selection() that only works in action chains. If you want a composite column (built from other columns) with the lookup name '#minutes' then you would use this template for the column.
Code:
program:
    $$#pagecount / 320
If you don't want fractional minutes then use
Code:
program:
    floor($$#pagecount / 320)
or
Code:
program:
    round($$#pagecount / 320)

Last edited by chaley; 09-24-2021 at 11:09 AM. Reason: Grammar
chaley is offline   Reply With Quote