The set widget is very useful for choosing between multiple options.
Understanding the logic of what combinations of the $set widget's 
attributes produce the desired outcome is essential to using it for such a 
requirement.
The discussion above was quite a revelation.

Here's a possible use.

If A is not empty, chose A
   If A is empty, chose B
      If B is empty, chose C
         If C is empty, chose D

A real case secenario occurred within the date() macro 
<https://groups.google.com/forum/?hl=en#!topic/tiddlywiki/_bbDpiiReic>:

In the macro, I wanted to choose a template based on:
If there is a *template-day* parameter ( *$template-day$* )
   Use that 
   If NO *template-day* parameter
      Use the *template* parameter ( *$template$* )
      If NO *template* parameter
         Use the *Custom Settings* field value (stored in    tiddler: 
*date-settings-tiddler*    field: *template-day* )
         If NO *Custom Settings*
            Use the template *default variable* ( *<<template-day-default>>* 
)

<$set name="temp" tiddler="date-settings-tiddler" field="template-day" 
emptyValue=<<template-day-default>>>
   <$set name="temp-template" filter="[enlist[$template$]]" 
value="$template$" emptyValue=<<temp>>>
      <$set name="template" filter="[enlist[$template-day$]]" 
value="$template-day$" emptyValue=<<temp-template>>>

         Code using <<template>>

      </$set>
   </$set>
</$set>

Note how the $set flow is an exact reverse of the logical requirement, 
where the most important variable ( *template-day* ) is tested last.

So, for those interested, attached is a: Set Widget Tester for attribute 
precedence tiddler.
Drag & drop it into your TiddlyWiki or tiddlywiki.com & hopefully quickly 
check the result of any combination of the set widget's parameters.

Regards.


On Monday, April 1, 2019 at 10:26:24 PM UTC+7, Jeremy Ruston wrote:
>
> Hi SS 
>
> That’s great, thank you. 
>
> > Testting shows: If there is a value attribute & no emptyValue attribute, 
> the value is returned irrespective of the filter's result. 
>
> I can confirm that behaviour, and I think it’s a bug. But… I’m not 100% 
> sure that we should fix it; it might be better just to revise the docs at 
> this point (the observed behaviour is simpler to describe in the docs). 
>
> Best wishes 
>
> Jeremy 
>
>

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/8937c358-e06c-4c2b-b408-b6bb97568be7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: Set Widget Tester for attribute precedence.tid
Description: Binary data

Reply via email to