combine of filters in makro

86 views
Skip to first unread message

Gerald Weis

unread,
Mar 23, 2020, 6:25:40 AM3/23/20
to TiddlyWiki
Hi friends,

i am trying to combine 2 filters.

but its don't work

thats my code and i don't know whats wrong.

\define tabcaption()
<caption>Messergebnis am
<$vars datum0={{{ [<currentTiddler>removeprefix[Körpertyp:]] }}} >
<$vars datum={{{ [<<datum0>>split[-]reverse[]join[.]] }}} >
<<datum>>
</$vars>
</
$vars>
</caption>
\end

Whats my Mistake

Tahnks for Help

TonyM

unread,
Mar 23, 2020, 6:44:31 AM3/23/20
to TiddlyWiki
Gerald,

If what you intended worked, the result would be;

[[<currentTiddler>removeprefix[Körpertyp:]]split[-]reverse[]join[.]]
Both [[ and ]] are invalid

Another problem I see is because variables inside filters, and fields etc.... only use one set of brackets
<$vars datum={{{ [<<datum0>>split[-]reverse[]join[.]] }}} >
Would be
<$vars datum={{{ [<datum0>split[-]reverse[]join[.]] }}} >

In filters only one bracket is required, but outside two brackets are needed otherwise they would be confused with HTML tags `<p>` etc...

Lets see if that gets you any further.

Bu the way one way to combine filters is using the subfilter operator https://tiddlywiki.com/#subfilter%20Operator

If you are still lost perhaps explain what you want rather than how it does not work.

Regards
Tony

Gerald Weis

unread,
Mar 23, 2020, 8:11:56 AM3/23/20
to tiddl...@googlegroups.com
Hello,

i give  an example

Name of the Tiddler
Körpertyp: 2020-03-11

introduction of the caption
Messwert am

string to split 
2020-03-11
indicatet string: 11.03.2020
caption complete Messwert am 11.03.2020

Also from the tiddlertitle Körpertyp:  2020-03-11 i want to have the Date-string (YYYY-MM-DD).
then i must have the split reverse for the date make in Date-german-format (DD.MM.YYYY)
The caption should be Messwert am (Date-german-format)

 and it is a lot of tiddler with this titlestructure..
question: Is it possible to have an filter like

{{{ [<currentTiddler>removeprefix[Körpertyp:]][split[-]reverse[]join[.]] }}}

thats dont work

Gerald Weis

unread,
Mar 23, 2020, 3:58:40 PM3/23/20
to tiddl...@googlegroups.com
Hey Guys

now i have the code new
\define tabueb()
<caption>Messergebnis am

<$vars datum={{{[<currentTiddler>removeprefix[Körpertyp:]]}}}>
<$vars datum0=
{{{ [<datum>split[-]reverse[]join[.]] }}}>
<<datum>>
<<datum0>>
</$vars>
</
$vars>
</caption>
\end

the code in the first <$vars> works
the code in the second <$vars> dont work.
It doesnt work with <datum> and with <<datum>>.

i ask me why.

i have give to notice <<datum>> and i have the value 2020-11-30 (date in format YYYY-MM-DD)
now i have give to notice <<datum0>> and i have seen nothing.
excepted was 30.11.2020 (date in format DD.MM.YYYY)

waht is wrong in the second condition?

TonyM

unread,
Mar 23, 2020, 5:05:08 PM3/23/20
to TiddlyWiki
Gerald,

Thank you for explaining what you want

I will work on a solution now

Regards
tony

TonyM

unread,
Mar 23, 2020, 5:28:32 PM3/23/20
to TiddlyWiki
Gerald,

I have responded to you requirement rather than continue with your method. I expect we could fix you method because there are some errors in your filter(s).

My approach was to deal with each step individually and capture intermediate values.

I hope my english is simple enough.

The following works
\define new-title() {{!!caption}} <<new-date>>
<$set name=title-date filter="[<currentTiddler>split[ ]]" select=1>
<$set name=new-date filter="[<title-date>split[-]reverse[]join[.]]">
title
-date=<<title-date>><br>
new-date=<<new-date>><br>
<<new-title>>
</$set></$set>

With an explanation, each note relates to above
\define new-title() {{!!caption}} <<new-date>>
<!-- using the new-title macro to "concatenate" multiple values -->

<$set name=title-date filter="[<currentTiddler>split[ ]]" select=1>
<!-- Using set/filter to split the currentTiddler title by space and use the select=1 to retrieve the 2nd item the title-date
 
(the first item is select=0) -->

<$set name=new-date filter="[<title-date>split[-]reverse[]join[.]]">
<!-- as determined previously saved as new-date -->

title
-date=<<title-date>><br>
new-date=<<new-date>><br>
<!-- Display the results for your information -->

<<new-title>>
<!-- the desired result -->

</$set></$set><!-- close the above set widgets -->

You could split the `<<title-date>>` with split[-] and use select 0,1 and 2 to retrieve year month day if you wanted to use them.

I will now consider bringing it together in one filter.

Regards
Tony

TonyM

unread,
Mar 23, 2020, 5:38:14 PM3/23/20
to TiddlyWiki
Gerald,

As I expected by breaking down the problem into steps, in my first example then using this reference it was much easier to generate a final result.

{{{ [<currentTiddler>split[ ]butfirst[]split[-]reverse[]join[.]addprefix[ ]addprefix{!!caption}] }}}

Your example was easy to test on tiddlywiki.com

In this case I use butfirst to get the second part of the title (the Date) so the one filter can pass only the date to the next part.
If you remove something in a filter (in this case from the title) you can allways add content back using addprefix/addsuffix and more, in this case we addprefix your caption.

Regards
Tony

TonyM

unread,
Mar 23, 2020, 8:25:25 PM3/23/20
to TiddlyWiki
Post Script;

I like this method extracted from the above discussion

{{{ [[2020.03.11]split[.]reverse[]join[.]] }}}

Regards
Tony

On Monday, March 23, 2020 at 9:25:40 PM UTC+11, Gerald Weis wrote:

TonyM

unread,
Mar 23, 2020, 9:36:42 PM3/23/20
to tiddl...@googlegroups.com
Further

We can also deal with the ugly USe date format
\define input() 12.31.2020
input
=<<input>><br>
{{{ [<input>split[.]butlast[]reverse[]join[.]] [<input>split[.]last[]addprefix[.]] }}}

Keep in mind YYYY0MM0DD is the prefered date format as it works with tiddlywiki standard dates the days operator etc...

Regards
Tony
Reply all
Reply to author
Forward
0 new messages