View Single Post
Old 07-13-2022, 08:54 AM   #418
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,476
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Question: Could book_values be used to check how many books in a series have a #percentread of 100, then return a value (e.g. read series, unread series, partially read series) based on that? This would probably be best done as a template search.
Sure. Something like this Edited:
Code:
program:
	vals = globals(vals = '');
	if !vals then
		all_series = book_values('series', 'series:true', ',', 0);
		for series in all_series:
			count = book_count('series:="' & series & '"', 0);
			reads = book_values('#myint', 'series:="' & series & '"', ',', 0);
			ans = '';
# I assume that an unread book has an undefined read percentage, not 0%
# If the reads list is empty then no book has a defined value
			if list_count(reads, ',') == 0 then
				ans = 'Unread series'
			fi;
			for i in reads:
# If any book isn't 100 then partially read
				if i != 100 then
					ans = 'Partially read series'
				fi
			rof;
			if !ans then
				ans = 'Read series'
			fi;
			vals = list_join(',', vals, ',', series & ':' & ans, ',')
		rof
	fi;
	select(vals, $series)

Last edited by chaley; 07-14-2022 at 11:25 AM. Reason: Added the missing call to globals(). Remove blank after 'program'
chaley is offline   Reply With Quote