View Single Post
Old 12-15-2014, 03:53 AM   #5
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,354
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Metaxil View Post
That worked (with a modification and a fix). You forgot to put #review as '#review' (easily fixed) and I added a format_number at the beginning so I didn't have a 6 decimal answer.
The modified formula for anyone else interested

Code:
program:format_number(
r = test(field('#chapters'),ifempty(field('#reviews'),'0'),'0');
c = ifempty(field('#chapters'),'1');ans = divide(r,c); 
cmp(ans,0,'','',ans),"{0:5.1f}")
I removed the comments, as they are explained above, for anyone interested. eschwartz, I appreciate your help.
I am astounded that this template works with assignment statements as parameters for the format_number function. The parser isn't supposed to let that through. I won't fix the "bug" though.

As the language was designed and as eschwartz said, your template should be
Code:
program:
r = test(field('#chapters'),ifempty(field('#reviews'),'0'),'0');
c = ifempty(field('#chapters'),'1');ans = divide(r,c); 
format_number(cmp(ans,0,'','',ans),"{0:5.1f}")
chaley is offline   Reply With Quote