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/f8b3337f-8b23-4cf1-ac7c-17df39caa9f1%40googlegroups.com.

Reply via email to