View Single Post
Old 05-08-2022, 06:09 AM   #461
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by Svens View Post
Friends,

So far, I have introduced the following templates into the settings of Kobo Touch extended, for book stats:

For LOWER program: round($$#words / 12000) -1)
For UPPER program: round($$#words / 12000)

And everything works beautifully - on the second Calibre connection, the statistics are displayed for each book (for me they are just kepub).

However, I want to add a bit of extra logic. Since reading time doesn't affect books containing less than 6000 words, the smallest time in that case becomes a negative integer
and, as a result, reading time is not displayed.
So, my question is if such logic can be introduced: if the words are below 6000 - then minimum time to be 0 hours, and maximum time to be 1 hour. If the words are more than or equal to 6000, the above calculations to be applied.
I.e. something like this:

For LOWER program: if ($$#words > 6000) then round($$#words / 12000) -1) else 0 fi
For UPPER program: if ($$#words > 6000) then round($$#words / 12000) else 1 fi

I've tried it, but it seems like there's something i'm not doing quite right. I will be happy if someone helps.
The point of using a template is that you can add code. My examples were just that, examples. Simple things that I used to test. I understand enough about the calibre templates, that I didn't need to do more.

As to what is wrong, you need to tell us. There is an error the template for the Lower estimate, but, I don't know if that is the actual issue or not. This has an extra parenthesis in it. If you used the Template editor it would show an error and try to tell you where it is. But, the correct template should be:

Code:
if ($$#words > 6000) then round($$#words / 12000) - 1 else 0 fi
Looking at these, I don't know what you are trying to do. The value for the estimates is supposed to be minutes. Which the device displays a hours. I am pretty sure that zero and one will be displayed as zero by the device or not display anything.
davidfor is offline   Reply With Quote