Eric, thanks for the clarity in my head! I assumed that the problem was the
difference between a field and a macro from a filter point of view, but I
did not understand exactly. I understand now. ...
Tested, IT IS OK! Yes! :)
So there are
1. validateregexp.js macro module
2.
\define validFilter()<$macrocall $name="validateregexp"
regexp={{!!add.filter}}/>
3. <$wikify name="thefilter" text=<<validFilter>>>
4. use in filter expression
If that's optimal way to use such macro then I should implement it in
another 3 places that I have
четверг, 15 октября 2020 г. в 14:07:05 UTC+6, Eric Shulman:
> On Wednesday, October 14, 2020 at 11:29:25 PM UTC-7, Shareda wrote:
>>
>>
>> \define validFilter()<$macrocall $name="validateregexp"
>> regexp={{!!add.filter}}/>
>> and change filter
>> [search:text:regexp{!!add.filter}]
>> to
>> [search:text:regexp<validFilter>]
>> then the second filter always returns nothing even if {!!add.filter}
>> and <validFilter> are equal and the first filter works correctly.
>>
>
> This is, perhaps, the most frequently misunderstood concept in TiddlyWiki:
>
> *** Macros are NOT functions ***
>
> They do not "evaluate their contents and return the results". Rather,
> they just perform TWO actions:
>
> 1) replace occurrences of $param$ with corresponding values passed as
> macro parameters
> 2) replace occurrences of $(variable)$ with corresponding values of
> variables define outside the macro
>
> After doing these replacements, the macro's literal contents are inserted
> in place of the macro call itself.
> It is then up to the calling context to do any rendering (aka,
> "wikification") of the results.
>
> Thus, your second filter becomes:
> [search:text:regexp<$macrocall $name="validateregexp" regexp={{!!add.
> filter}}/>]
> and filter operators do NOT process widgets. Thus, the regexp filter
> operator sees it's parameter
> as a reference to a variable named "$macrocall". In addition, variable
> references inside filters do
> not allow use of arguments, so the rest of the $macrocall -- the $name...
> and regexp... parts -- are ignored.
>
> In effect, your filter is:
> [search:text:regexp<$macrocall>]
> and since there is no variable named "$macrocall", it is trying to match a
> blank pattern which,
> of course, produces no results.
>
> To actually get the rendered results of the validateregexp $macrocall, you
> need to use the
> <$wikify> widget to process and capture the *output* of the validFilter()
> macro into a variable,
> and then use that variable in the filter. Something like this:
>
> <$wikify name="thefilter" text=<<validFilter>>>
> ...
> [search:text:regexp<theFilter>]
> ...
> </$wikify>
>
> I hope this explanation doesn't make your head explode. :)
> https://www.youtube.com/watch?v=B_Lnz64vXB8
>
> Let me know how it goes...
>
> -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/71de9f86-9077-448f-935a-cc7d9294229bn%40googlegroups.com.