View Single Post
Old 12-21-2019, 12:07 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,506
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Try this:
Code:
program:
	read = raw_field('#pages_read');
	total = raw_field('#total_pages');
# if total <= 0 (or undefined), set read to 0
	read = cmp(total, 0, 0, 0, read);
# make sure the dividend (total) != 0 
	total = cmp(total, 0, 1, 1, total);
	percent = multiply(divide(read, total), 100);
	cmp(percent, 0, '', '', format_number(percent, "{0:2d}"))
The custom column definition looks like this:
Attached Thumbnails
Click image for larger version

Name:	Clipboard01.jpg
Views:	200
Size:	41.0 KB
ID:	175795  
chaley is offline   Reply With Quote