Quote:
Originally Posted by Svens
On the next 4 screenshots,i'm using the following templates:
program:if ($$#words > 6000) then round(($$#words / 12000) - 1) else 0 fi
program: if ($$#words > 6000) then round($$#words / 12000) else 1 fi
Here, the results are very contradictory - some are OK, others are totally wrong. And I can't understand why.
|
I think I understood why. It looks like in the boolean condition #words is evaluated as a text string and the comparison is performed considering the alphabetic order! With this wrong interpretation you get for example "7">"6000"!
This is weird considering that #words is an integer!
try this instead:
Code:
program:if round($$#words / 12000) > 1 then round($$#words / 12000) - 1 else 0 fi
program:if round($$#words / 12000) > 1 then round($$#words / 12000) else 1 fi
Even though it is a little redundant (you divide and round twice in case the condition is returning true), this is forcing Calibre to manage it as an integer and... It works!
Does anybody know whether it is possible to force Calibre to consider it as an integer without performing an arithmetic operation? This would save computing time.