Thank you @Mark. It seems the {{{filter...}}} has a lot of potential to
create conditional statements. The actual use case was based on the user
interaction a set of classes shall be applied to few html tags. I used the
dictionary tiddler, but for small use cases I like your approach.

@Tones, thank you. I like these kinds of threads where the scripting
features of TW are discussed and I always learn new things.

Thank you Jed, Mat, Mark, and Tones.


Best wishes
Mohammad


On Mon, Jan 25, 2021 at 4:00 AM 'Mark S.' via TiddlyWiki <
tiddlywiki@googlegroups.com> wrote:

> Maybe too literal, but easier to read and extend:
>
> \define myfun(x)
> <$vars u={{{ [enlist[xxx one two three four]allbefore<__x__>count[]] }}} >
>   This is u: <<u>>
> </$vars>
> \end
>
>
>
> On Sunday, January 24, 2021 at 2:24:58 AM UTC-8 Mohammad wrote:
>
>> I tried to implement the below pseudo code in TW 5.1.23
>>
>> if x=one then
>>   print(1)
>> elseif x=two then
>>  print(2)
>> elseif x=three then
>>  print(3)
>> else
>>  print(x is not valid)
>> end
>>
>> with
>>
>> \define myfun(x)
>> <$vars u={{{[<__x__>match[one]then[1]] [<__x__>match[two]then[2]]
>> [<__x__>match[three]then[3]]  +[addsuffix[ lili]]  ~[<__x__>addsuffix[ is
>> not valid]]}}} >
>>   This is u: <<u>>
>> </$vars>
>> \end
>>
>>  It works fine on https://tiddlywiki.com/   by calling macro as below
>>
>> <<myfun one>>
>> <<myfun two>>
>> <<myfun three>>
>> <<myfun four>>
>>
>> I wish to know is this a good practice in TW 5.1.23? If not what better
>> solution do you propose?
>>
>>
>> Best wishes
>> Mohammad
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/99c1cf6c-db74-491b-85e2-8b45e729dab2n%40googlegroups.com
> <https://groups.google.com/d/msgid/tiddlywiki/99c1cf6c-db74-491b-85e2-8b45e729dab2n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CAAV1gMCAL6EyBL6jJ0u%2BqMCo68-%3D-ve%2B1d_fzcG3-7WL_uSqNQ%40mail.gmail.com.

Reply via email to