store filter output in variable for later narrowing down

51 views
Skip to first unread message

sjaakad...@ziggo.nl

unread,
Jan 17, 2021, 4:13:00 PM1/17/21
to TiddlyWiki

Hi all,

I want to store the output of a filter in a variable and use that variable later in a second filter to narrow the result down, and so on.

In preparation I made several test tiddlers with both tag1 and tag2 as tags. Then I tried:

<$set name="fil1" filter="[tag[tag1]]">
<$set name="fil2" filter="[<fil1> +[tag[tag2]]">
<$text text=<<fil1>>>
<$text text=<<fil2>>>
</$set>
</$set>

The output of fil1 comes out allright, but I can't seem to make fil2 work (I get either no result at all, 'Missing [' or 'Syntax error'). To be complete: the test tiddlers have one-word titles.
I believe I tried all possible combinations of square and arrow brackets in the definition of fil2 but no luck. I also tried putting in another set statement like this, in order to fiddle a bit more:

<$set name="fil1" filter="[tag[tag1]]">
<$set name="fil3" filter="[<fil1>]">. <!-- and variations. -->
<$set name="fil2" filter="[<fil2> +[tag[tag2]]">
<$text text=<<fil1>>>
<$text text=<<fil3>>>
<$text text=<<fil2>>>
</$set>
</$set>

No success. I really am stupefied here. Can someone explain what I should do and why all this does not work?

Greetings,
Sjaak

Mark S.

unread,
Jan 17, 2021, 4:43:09 PM1/17/21
to TiddlyWiki
"fil2" was missing a right square bracket. In addition, you're attempting to pass a filter to a filter. You can do this if you use the subfilter operator. You also need to terminate your text widgets with a final slash (/). So we end up with this:

<$set name="fil1" filter="[tag[tag1]]">
<$set name="fil2" filter="[subfilter<fil1>]+[tag[tag2]]">
<$text text=<<fil1>>/>
<$text text=<<fil2>>/>
</$set>
</$set>


sjaakad...@ziggo.nl

unread,
Jan 18, 2021, 10:57:23 AM1/18/21
to TiddlyWiki
Hi Mark,

Thanks a lot! The mistakes in the square brackets department must have crept in during the copy&paste series.
Your solution with subfilter worked perfectly. I still do not understand why you cannot just put the variable name fil1 between angle brackets inside the filter expression for fil2, because the output of fil1 looks OK to me and a series of tiddler names makes up a valid filter expression (isn't it?), but hey.

I noticed that if in fil1 you use the value parameter instead of the filter, fil2 also works fine (in this simple case, that is, maybe not in more complex cases). So that would be:

<$set name="fil1" value="[tag[tag1]]">

<$set name="fil2" filter="[subfilter<fil1>]+[tag[tag2]]">
<$text text=<<fil1>>/>    <!-- this now gives "[tag[tag1]]" -->
<$text text=<<fil2>>/>    <!-- works!  -->
</$set>
</$set>


Thanks again!

Greetings,
Sjaak


Reply all
Reply to author
Forward
0 new messages