Quote:
Originally Posted by un_pogaz
Else, if retrive the seleted book ids is good, I think it would be much more useful to have a function 'search_books()' that use the search syntax.
Code:
ids = search_books('series:"='&field('series')&'"')
rlst = ''
for id in ids:
with id:
rlst = rlst & character('newline') & $title
htiw;
rof;
show_in_dialog(rlst) # show all the books in a series
|
Use the function book_values(), as in
Code:
ids = book_values('id', 'series:"=' & field('series') & '"', ',', '0')
Quote:
And let's even be bold, adding a 'all_ids_books()', that way, we can run the entire library.
|
Use this. The null search expression matches everything.
Code:
ids = book_values('id', '', ',', '0')
Quote:
(this two function would also greatly benefit to have a optional argument virtual libray)
|
The fourth parameter tells book_values() whether or not to use the current VL. If you want to use an arbitrary VL then put it in the search expression. For example, this expression returns the ids of all the books in the 'foo' VL:
Code:
ids = book_values(id, 'vl:foo', ',', '0')
Quote:
But now that I think about it, I don't think the template editor is designed for that kind use, since it executes the code at each edit... it would become a hell to creat such things. So in addition, I think it would be useful to add a new mode that only executes code on demand.
Nevermind, their is the Breakpoints mode that already do that, Yes.
(however, you must not select such stored template without the Breakpoints mode enable, else your cooked)
|
Yes, editing a template without breakpoints enabled is painful. I always have it on even when I'm not actually using breakpoints.
NB: I'm also adding a way to execute the template tester where it doesn't run the template for all the selected books, ignoring all but the first book. This helps develop and use templates that iterate over selected ids, generating reports.