Dynamic creation of filters !!!
Say that one has an untold number of numeric fields spread throughout a TiddlyWiki instance, all of those fields having names that match a pattern.
(For example: say all of the fields have “aaa” in their names.)
And say any one tiddler can have an untold number of those fields (0 to many).
How would we go about summing all of these fields, specifying only a pattern for field names, and without knowing which tiddlers have those fields?
As an exercise, here’s my approach. Download attached and drag into TiddlyWiki.com for study.
For convenience, here is the code of interest:
\define p1() [get[ \define p2() ]] \define p3() +[sum[]] <$list variable="thisField" filter="[fields[]regexp[aaa]]"> sum of <> values: <$list filter="[getsum[]]"> {{!!title}}
**<$vars thisDynamicFilter={{{ [fields[]regexp[aaa]addprefixaddsuffix] [] +[join[ ]] }}}>** <$list filter={{{ **[]** }}}> ''total:'' <>
Good fun !
SuperDuperSumming.json (790 Bytes)