@capink: I have been thinking about something I would find useful, but a) I am not sure anyone else would, and b) whether the idea fits inside your plans/ideas for action chains.
The idea: sometimes I want to compute some value for a set of books. Some easy examples are the sum of some column, how many series does an author write, names of series for an author, etc. These can all be computed using a template if
- it could be run on a selection
- it could pass information between invocations
- the computed information can be displayed
The "passing information" could be solved by a template function that modifies the globals dict. This works as long as the same dict is passed to the template for each book, which I suspect is what you do for a chain.
The "run on selection" could be done with a new built-in action that runs the provided template on each selected book. The information could be displayed by providing a built-in action that shows the values in the globals dict in a dialog. If really fancy it could take a set of pairs ('global_var_name': 'display_name'). The action would display the listed globals using the display_name. Alternatively, computing and displaying might be done by changing the "formula" action to (optionally?) run over the selection, and to display some values from the globals dict.
With these changes I could create an action that sets up variables (if needed), runs a template that computes what is needed and saves the result to globals, then runs an action that displays the answer.
To continue the example, a template that counts the number of series in a selection could be:
Code:
program:
s = field('series');
globals(series_seen='', series_count=0);
series_seen = list_union(series_seen, s, ',');
series_count = count(series_seen, ',');
# the new function to change the globals dict
set_globals(series_seen, series_count)
What do you think?