Quote:
Originally Posted by chaley
FWIW: I'm currently implementing these changes to the base formatter. - ids = selected_books()
- name = selected_cell(). Returns the lookup name.
- A 'with' statement that changes the book the template is using for the statement's block. The same local variables are available to the inner and outer block.
EDIT: I'm also going to implement "show_in_dialog()" that renders an html string.
|
Oh, it would be inded quite usefull to test all the selected books inside the singular Template call of the condition settings. But that dosn't solve the issue to perform some actions only on a specific subset on seleted books.
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
And let's even be bold, adding a 'all_ids_books()', that way, we can run the entire library.
(this two function would also greatly benefit to have a optional argument virtual libray)
Damn, it will make the GPM incredible powerfull, able to execute an return big data for a one of execution. Python template are great, but GPM is much simpler and enough for 90% of case, and the 'with' statement will make it a "complet" language in a some way.
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)