View Single Post
Old 02-22-2014, 01:47 AM   #322
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 embryo View Post
That is a nice idea.
There is this thing though.
When I have the formating like this: {0:,} I get a "TEMPLATE ERROR invalid literal for float(): 54,916"
It works only if I change the formating to {0}, but then, the word count number is more difficult to be read.
There is this "re()" function I've read about, but since I don't know anything about programing, I don't know how to implement it. I'm experimenting, but ...
Any thoughts?
I did notice that, but I cheated and removed the formatting of the number

I had a look through the list of template functions and found "raw_field". That returns the raw value of a column. Using that, the following works:

Code:
{:'cmp(raw_field('#words'), 40000, cmp(raw_field('#words'), 17500, cmp(raw_field('#words'), 7500, '', 'Novelette', 'Novelette'), 'Novella', 'Novella'), 'Novel', 'Novel')'}
Doing the same thing in program mode is:

Code:
program: 
words=raw_field('#words');
shelf_name=cmp(words, 40000, cmp(words, 17500, cmp(words, 7500, '', 'Novelette', 'Novelette'), 'Novella', 'Novella'), 'Novel', 'Novel');
That's still pretty unreadable. A lot better is:

Code:
program: 
words=raw_field('#words');
shelf_name=cmp(words, 7500, '', 'Novelette', 'Novelette');
shelf_name=cmp(words, 17500, shelf_name, 'Novella', 'Novella');
shelf_name=cmp(words, 40000, shelf_name, 'Novel', 'Novel');
And something I hadn't realised before is that the template for this type of column can be changed from the library list. Click in the column to select it, and then either click again or press F2 to open an editor on the template. When changing the template, it is tested using the selected book and the results are shown.
davidfor is offline