This may also be a good opportunity to point out in macros you can also access the content of a variable defined outside the macro, as a substitution using the form $(varname)$ eg $(tag2)$
Tones On Friday, 18 June 2021 at 00:02:46 UTC+10 Eric Shulman wrote: > On Thursday, June 17, 2021 at 5:45:48 AM UTC-7 [email protected] > wrote: > >> \define countTag2() >> <<tag2>>: <$list filter="[tag[<<tag2>>]count[0]]"/> >> \end >> >> <$set name=tag2 value=picture> >> <<countTag2>> >> </$set> >> >> Result: picture 0 >> I have 2 tiddlys with the tag picture. Why the result is different???? >> > > The difference is that when specifying a filter operand, you *use square > brackets only with literal operand values*. Thus, in the first macro, > because the $tag$ is a *macro parameter* that is automatically > *substituted* into the filter syntax by the TWCore macro processor, you > correctly wrote tag[$tag$]. However, in the second macro, tag2 is a > *variable* that is *referenced* by the tag filter and, when using a > variable as the operand of a filter operator, you *use single angle > brackets to surround a variable operand reference*, instead of the square > brackets you used previously for the literal $tag$ operand value. Thus, > you need to use: tag<tag2> in your filter syntax. > > Your second macro should be written as: > \define countTag2() > <<tag2>>: <$list filter="[tag<tag2>count[0]]"/> > \end > > enjoy, > -e > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/53e12d86-a520-41d8-9936-c054c68cfaa3n%40googlegroups.com.

