View Single Post
Old 11-15-2023, 12:13 PM   #2
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,463
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by crnirg View Post
How can I make my column in which the length (size) of the COMMENTS column will be in characters or maybe just whether it is more or less than say 50?
Make a "Column built from other columns" with the heading and lookup name whatever you want.

To show the length, set the template to this Single Function Mode template and set the column's Sort/search type to "Number".
Code:
{comments:strlen()}
To make it say "Yes" if the length is greater than or equal to 50, otherwise "No" use this Template Program Mode template
Code:
{comments:'cmp(strlen($), 50, 'No', 'Yes', 'Yes')'}
or this General Program Mode template
Code:
program:
	if strlen($comments) >=# 50 then 'Yes' else 'No' fi
or this Python Template Mode template
Code:
python:
def evaluate(book, context):
	comments = book.get('comments')
	return 'Yes' if comments and len(book.get('comments')) >= 50 else 'No'
chaley is offline   Reply With Quote