Quote:
Originally Posted by rolgiati
I am trying to update my library, to check that I have the latest(s) book(s) in each of the Series I have been reading.
Is there a way, for all the Series in a library, to selet only the books with the highest Series_Index of each Series ?
|
You can do that with a template search that finds all series, finds the book(s) with highest index, then shows those books. This one works for me.
Code:
template:"""program:
vals = globals(vals='');
if !vals then
all_series = book_values('series', 'series:true', ',', 0);
for series in all_series:
indices = book_values('series_index', 'series:="' & series & '"', ',', 0);
first = 1;
highest = 0;
for index in indices:
if first || index ># highest then highest = index; first = '' fi
rof;
vals = list_union(vals, series & ':' & highest, ',')
rof;
set_globals(vals)
fi;
if $series && $series_index ==# select(vals, $series) then '1' fi#@#:n:1"""
If you use the Advanced search builder in the search bar then the template is this:
Code:
program:
vals = globals(vals='');
if !vals then
all_series = book_values('series', 'series:true', ',', 0);
for series in all_series:
indices = book_values('series_index', 'series:="' & series & '"', ',', 0);
first = 1;
highest = 0;
for index in indices:
if first || index ># highest then highest = index; first = '' fi
rof;
vals = list_union(vals, series & ':' & highest, ',')
rof;
set_globals(vals)
fi;
if $series && $series_index ==# select(vals, $series) then '1' fi
The Comparison type is Number and the Template value is 1