View Single Post
Old 04-21-2011, 04:04 PM   #11
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,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Starson17 View Post
I'm not certain I understand you, but I think you want to find books where the comments field has content, but not much content. I suspect you need the len() function. I'm pretty sure you can't do that with search. You might be able to do it by creating a custom column, but a quick check through the functions available didn't turn up len. I suspect we need Charles the guru for this one.
The function you are looking for is count. The following template
Code:
program:cmp(count(field('comments'), ' '), 15, 'true', 'true', 'false')
uses count to generate 'true' if comments contains 15 words or less, and 'false' for more than 15. A word is defined as not-spaces separated by spaces.

You could just as easily use
Code:
program:count(field('comments'), ' ')
in a column with sort/search type 'number', then use the search expression
Code:
#column:<=15
Edit: If you want the basic length, you can use strlen instead of count.
chaley is offline   Reply With Quote