Quote:
Originally Posted by Soap-dodger
Apart from one use case, this works, returning a floating point value. I need to work out how to round the returned value to a whole number, though.
The only time it doesn't work is when both #words and #pages contain null values. In this case, I get the following error message:
Code:
EXCEPTION: float division by zero
Can you help solve these issues?
|
Starting with the code posted by
@davidfor, you could use something like the code below to format numbers as integers and use 'undefined' instead as '0', since those will appear on the book details pannel (that bothers me

).
Code:
program:
pages = cmp(raw_field('#pages'),0,1,1,raw_field('#pages'));
words = cmp(raw_field('#pages'),0,0,0,raw_field('#words'));
wpp = format_number(divide(words,pages),'{0:.0f}');
cmp(wpp, 0, '', '', wpp)