JanJo
November 14, 2023, 9:10pm
1
Sorry to bother you with this… I am a little dumb right now.
How do I get the name of the tiddler as a param into a filter within macro
\define indexoverview(tid:{{$:/state/listen}})
<$list filter="[<tid>get[text]splitregexp[\n]]" variable=each-line>
<$list filter="[<each-line>split[:]first[]]">
*{{!!title}}<$list filter="[<each-line>split[:]nth[2]]">: {{!!title}}</$list>
</$list>
\end
<$select tiddler="$:/state/listen">
<$list filter='[all[shadows+tiddlers]prefix[$:/list/]]'>
<option value=<<currentTiddler>>>{{{[{!!title}removeprefix[$:/list/]]}}}</option>
</$list>
</$select>
<<indexoverview >>
Are you asking for [<tiddler>get[title]] – isn’t it already that?
JanJo
November 14, 2023, 9:56pm
3
No I mean that […] should be in this case “$:/state/listen”…
This can happen to us all.
I think your question is answered, if not indirectly, in this reply of mine about different ways to pass parameters to macros Attribute assignment where the attribute is computed - #7 by TW_Tones
However if you are using define rather than procedure you may use $(varname$) or $paramname$ inside the macro, and for completeness <<__paramname__>> (From Eric)
If I understand your indexoverview macro, you want to pass in the name of a tiddler whose text field contains a tiddler title whose text field you want to access (i.e., a “double indirection”).
If this is the case, then try something like this:
\define indexoverview(tid:"$:/state/listen")
<$list filter="[<__tid__>get[text]get[text]splitregexp[\n]]" variable=each-line>
<$list filter="[<each-line>split[:]first[]]">
*{{!!title}}<$list filter="[<each-line>split[:]nth[2]]">: {{!!title}}</$list>
</$list>
\end
Notes:
You can’t use {{...}} to set the default value within the macro parameter list, so change that to just a quoted string with the default tiddler title.
In the first $list filter:
use <__tid__> to refer to the parameter value (i.e., “$:/state/listen”)
followed by get[text] to fetch the contents of “$:/state/listen” (i.e., the name of the tiddler selected in the $select list)
followed by ANOTHER get[text] to fetch the contents of that selected tiddler
enjoy,
-e
JanJo
November 14, 2023, 11:54pm
6
Thanks to you all I made the solution below to keep the possibility to enter other tiddlernames to the macro to use it in other places without the select-widget just like <<indexoverview “dictTid”>>
\define indexoverview(tid)
<$list filter="[<__tid__>get[text]splitregexp[\n]]" variable=each-line>
<$list filter="[<each-line>split[:]first[]]">
*{{!!title}}<$list filter="[<each-line>split[:]nth[2]]">: {{!!title}}</$list>
</$list>
\end
<$select tiddler="$:/state/listen">
<$list filter='[all[shadows+tiddlers]prefix[$:/list/]]'>
<option value=<<currentTiddler>>>{{{[{!!title}removeprefix[$:/list/]]}}}</option>
</$list>
</$select>
<$macrocall $name="indexoverview" tid={{$:/state/listen}}/>