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/f95b8f6a-320a-4834-946a-a8817520b473n%40googlegroups.com.

Reply via email to