[tw5] Re: Set value of a variable conditionally

2020-05-22 Thread 'Mark S.' via TiddlyWiki
Try ... <$vars variable="12345678"> <$set filter="[length[]compare:number:gteq[9]else[short]] [ length[]compare:number:lt[9]else[long]] +[sort[]last[]]" name=type select=0 > <> On Wednesday, May 20, 2020 at 9:19:59 AM UTC-7, Tony K wrote: > > I can't figure out how to set the value of a var

[tw5] Re: Set value of a variable conditionally

2020-05-21 Thread Tony K
Hi Mark in your below example type will be equal to "long" online inside else() however inside the section {full code here 1} it won't actually the section {cull code here 1} won't even be reached Please tell me if I am mistaken On Thursday, May 21, 2020 at 5:34:15 PM UTC+3, Mark S. wrote:

[tw5] Re: Set value of a variable conditionally

2020-05-21 Thread 'Mark S.' via TiddlyWiki
But you can set a variable inside a macro: \define else() <$set name="type" value="long"> <> \end <$vars variable="variable"> <$list filter="[length[]match[9]]" emptyMessage=<>> <$set name="type" value="short"> {full code here 1} All that matters is that the alternate "else" does whatever ta

[tw5] Re: Set value of a variable conditionally

2020-05-20 Thread TonyM
Tony K Ok, I do not understand the original question then however perhaps these could help? - Have you tried to use set, its filter and emptyValue which should remain until the closing set? - Can you ask the question in a different order? - Or can you generate a subset of variables

[tw5] Re: Set value of a variable conditionally

2020-05-20 Thread Tony K
Hello Tony Your patience is remarkable thank you so much yes I am aware that an empty messaeg can be a macro however I wasn't able to make it set the value of the same variable for the rest of the code like explained by Saq and yourself in the if-then-else scenario the second issue I faced is

[tw5] Re: Set value of a variable conditionally

2020-05-20 Thread TonyM
TonyK An empty message can be a macro, that contains many things, \define onemptymessage() {empty message code here} \end <$list filter="""[length[]match[9]then[short]else[long]]""" variable="type" emptyMessage=<> /> {full code here} It can even look like this <$list filter="""[length[]m

[tw5] Re: Set value of a variable conditionally

2020-05-20 Thread Tony K
Saq does it again :) :) thank you I shld have asked ages ago Cheers On Wednesday, May 20, 2020 at 7:29:47 PM UTC+3, Saq Imtiaz wrote: > > Eg: > > <$list filter="""[length[]match[9]then[short]else[long]]""" > variable="type"/> > > {full code here} > > > > On Wednesday, May 20, 2020 at 6:28:11 PM

[tw5] Re: Set value of a variable conditionally

2020-05-20 Thread Tony K
I did play around with empty message but it gives an empty message and doesn't set a value to a variable (at least from my tests) On Wednesday, May 20, 2020 at 7:26:41 PM UTC+3, Mark S. wrote: > > The list widget has an emptyMessage attribute. You can point this to a > macro where alternative ac

[tw5] Re: Set value of a variable conditionally

2020-05-20 Thread Saq Imtiaz
Eg: <$list filter="""[length[]match[9]then[short]else[long]]""" variable="type"/> {full code here} On Wednesday, May 20, 2020 at 6:28:11 PM UTC+2, Saq Imtiaz wrote: > > Many combinations of list and set widgets can be used, but this basic idea > is probably what you need: > > [length[]match[

[tw5] Re: Set value of a variable conditionally

2020-05-20 Thread Saq Imtiaz
Many combinations of list and set widgets can be used, but this basic idea is probably what you need: [length[]match[9]then[short]else[long]] On Wednesday, May 20, 2020 at 6:19:59 PM UTC+2, Tony K wrote: > > I can't figure out how to set the value of a variable based on a specific > condition s

[tw5] Re: Set value of a variable conditionally

2020-05-20 Thread 'Mark S.' via TiddlyWiki
The list widget has an emptyMessage attribute. You can point this to a macro where alternative actions occur when the main filter fails (is empty). In your second set of widgets, you have unmatched tags/tag endings which is always a bad thing. Good luck! On Wednesday, May 20, 2020 at 9:19:59 A