Thank you Jed,
I have not used the lookup operator, seems promising. I will give a try.


Best wishes
Mohammad


On Sun, Jan 24, 2021 at 2:41 PM Jed Carty <[email protected]> wrote:

> I don't see anything wrong with using that macro, but I do have an
> alternative that I think is more flexible.
> Depending on the situation this may not work, but here is the same result
> using lookup:
>
> \define myfun(x)
> <$vars u={{{ [<__x__>lookup:$x$ doesn't exist[value ]] }}}
> \end
>
> then you make a series of tiddlers with the titles 'value one', 'value
> two', 'value three'  with 1, 2 and 3 in their text fields.
>
> The downside is that you can't distribute it as just the macro, the
> benefit is that you can extend it to as many options as you want without
> editing the macro.
>
> On Sunday, January 24, 2021 at 11:34:00 AM UTC+1 Mat wrote:
>
>> Very minor but for readability you can break the line in multiple places.
>>
>> <:-)
>>
>> On Sunday, January 24, 2021 at 11:24:58 AM UTC+1 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/63dedb45-c31a-4a78-9733-caecd865df0an%40googlegroups.com
> <https://groups.google.com/d/msgid/tiddlywiki/63dedb45-c31a-4a78-9733-caecd865df0an%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CAAV1gMBXmJwitFQsxrx98Ropx3jW2tr9eYJbGn4G3PQ2Trc2iQ%40mail.gmail.com.

Reply via email to