Hi Jeremy,
 That sounds good! I will also file a  feature request 
<https://github.com/Jermolene/TiddlyWiki5/issues/4064> for this and 
hopefully have a <$switch>/<$case> widget pair after 5.1.20

--Mohammad

On Friday, July 5, 2019 at 1:11:34 AM UTC+4:30, Jeremy Ruston wrote:
>
> Hi Mohammad
>
> Your construction with list widgets is a pretty good approximation of a 
> switch/case construction. The only frustration is that it is possible for a 
> value to trigger more than one of the list widgets; it would be better if 
> there was a way to make things stop after the first match.
>
> One could certainly imagine a <$switch>/<$case> widget pair that could 
> resolve that issue and might be more efficient as well. Perhaps after 
> v5.1.20
>
> Best wishes
>
> Jeremy
>
> On 4 Jul 2019, at 10:06, Mohammad <mohamma...@gmail.com <javascript:>> 
> wrote:
>
> In Javascript, C, C++ we have a programming construct called Switch-Case
>
> See : JS: https://www.w3schools.com/js/js_switch.asp, 
>
> switch(*expression*) {
>   case *x*:
>
> *    // code block*    break;
>   case *y*:
>
> *    // code block*    break;
>   default:
>     // *code block*
> }
>
>
> This code can do equivalent operation! Is this according to TW good 
> programming practice?
> Is there any better solution? I think looking in list items may be another 
> solution! Does anybody has tried such solution before? 
>
>
> \define items() One Two [[Three Four]] Five
>
> \define switch(item)
> <$list filter="[enlist<items>search<__item__>]" emptyMessage="Zero">
> <<currentTiddler>>
> </$list>
> \end
>
> <<switch One>>
> <<switch "Three Four">>
> <<switch "Ten">>
>
>
> This line
>
> <$list filter="[enlist<items>search<__item__>]" emptyMessage="Zero">
>
> Can be like this also
>
> <$list filter="[enlist<items>title<__item__>]" emptyMessage="Zero">
>
>
> What do you think?
>
> -- 
> 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 tiddl...@googlegroups.com <javascript:>.
> To post to this group, send email to tiddl...@googlegroups.com 
> <javascript:>.
> 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/b5fb6465-db3a-4809-a878-5b475f3c1b99%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/tiddlywiki/b5fb6465-db3a-4809-a878-5b475f3c1b99%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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/4ca23c7a-7938-458b-beb5-d61bad2a361c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to