Hi Tony This is interesting! Could you give some simple examples?
We need to wrap inside a macro to present a construct like <<select-case condition array-of-cases>> What do you think? I use a lot $list as if *filter**-not-**empty* do-this *else* do-that - filter is not empty do what is given inside $list widget - filter is empty go for emptyMessage --Mohammad On Friday, July 26, 2019 at 8:50:31 AM UTC+4:30, TonyM wrote: > > I just wanted to share this code pattern I just discovered for Handling > the emptyMessage condition in the ListWidget Body. > > Sometimes the way we write Filters the only way to proceed is to use the > emptyMessage to deal with the null case. > > If the Null case response requires multiple lines of wiki text it gets a > little messy > > \define macrodef() > If condition not met > \end > > > <$list filter="condition" emptyMessage=<<macrodef>> > > If Condition met > </$list> > The macro def must be at the top and it is removed from the list widget > > > OR > <$list filter="condition" emptyMessage=""" > > If condition not met > """> > If Condition met > </$list> > This makes me nervous :) > > So I developed this method/pattern > <$list filter="[is[current]tagging[]] ~[[::false]]" variable=result> > <$list filter="[<result>prefix[::]]" variable=case> > Do this if <<case>> > </$list> > <$list filter="[<result>!prefix[::]]" variable=case> > Process tiddler "<<case>>"<br> > </$list> > </$list> > Using the unlikely tiddler title "::false" to flag the empty set condition. > In this case the null *case* is executed once and the "no null case" as > many times as needed. > > *And did I mention "case"?* > > This structure also allows us to build a CASE structure with a default > behaviour. > > That is if a variable or field contains one of a number different values, > and you wish to respond differently for each > > <$list filter="[<casevariable>] ~[[::false]]" variable=case> > <$list filter="[<case>prefix[::false]]" variable=case> > Do this if no case value > </$list> > <$list filter="[<case>prefix[caseone]]" variable=case> > Process "caseone"<br> > </$list> > <$list filter="[<case>prefix[casetwo]]" variable=case> > Process "casetwo"<br> > </$list> > <$list filter="[<case>prefix[casethree]]" variable=case> > Process "casethree"<br> > </$list> > <!-- Even this --> > <$list filter="[<case>prefix[casetwo]] [<case>prefix[casethree]]" > variable=case> > Process "casetwo" and "casethree"<br> > </$list> > </$list> > > With the mathematics operators > > More will be possible? > > Regards > Tony > > > > > -- 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/2390a2fb-babb-4403-98ad-42ea6ad92532%40googlegroups.com.

