[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-04 Thread Mohammad
There is a small caveat. One should take care of Empty value! The empty value is interpreted as 0! -- 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

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-04 Thread Mohammad
Added to TW-Scripts On Sunday, August 4, 2019 at 10:41:03 AM UTC+4:30, TonyM wrote: > > Mohammad, > > Comparing two values for which is the greater - 5.1.20 ONLY because it > uses match and min operators > > <$set name=input1 value=3> > <$set name=input2 value=5> > > > <$list filter="=[!match]"

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-04 Thread Mohammad
Really smart solution! :-) I am working to see how we can do branching using only $list widget and it seems It can be used in many cases! The $list widget seems NOT a simple iterator and almost do many things just its name is misleading for many users --Mohammad On Sunday, August 4, 2019 at

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-04 Thread TonyM
Mohammad, Comparing two values for which is the greater - 5.1.20 ONLY because it uses match and min operators <$set name=input1 value=3> <$set name=input2 value=5> <$list filter="=[!match]" emptyMessage="equals"> <$list filter="=[minmatch]"> Input 1 = Minimum <$list

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-04 Thread TonyM
Mohammad See your conditional operators link for my answer to your Question One question, how do you propose to implement the below construct [Less > than and greater than tests] using $list widget Tony On Sunday, August 4, 2019 at 12:15:09 AM UTC+10, Mohammad wrote: > > Tony! > >> See

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-03 Thread TonyM
Great stuff -- 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

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-03 Thread Mohammad
Tony! > See this post! > https://groups.google.com/d/msg/tiddlywiki/xiCrpbATFqE/w-UjRxroFQAJ -- 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

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-03 Thread Mohammad
Tony Have a look here, then else operator https://github.com/Jermolene/TiddlyWiki5/issues/4147 On Saturday, August 3, 2019 at 4:00:07 PM UTC+4:30, TonyM wrote: > > Mohammad, > > Your first resort would be to the reveal widget since it already permits > such comparisons. I had raised the

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-03 Thread Mohammad
Yes, the reveal widget is one solution! It is important to have a readable and maintainable code! --Mohammad On Saturday, August 3, 2019 at 4:00:07 PM UTC+4:30, TonyM wrote: > > Mohammad, > > Your first resort would be to the reveal widget since it already permits > such comparisons. I had

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-03 Thread TonyM
Mohammad, Your first resort would be to the reveal widget since it already permits such comparisons. I had raised the development of less than and greater than operators but there is a real issues these raise because such tests need to take account of the complexity inherent in numbers. I am

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-03 Thread Mohammad
Tony, One question, how do you propose to implement the below construct using $list widget if a>b then do this part one else if a > Your welcome > > So on 5.1.20 > <$list filter="[] ~[[false]]" variable=case> ><$list filter="[match[false]]" variable=case> > Do this if no case

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-03 Thread Mohammad
Added to TW-Scripts! On Thursday, August 1, 2019 at 3:46:23 AM UTC+4:30, TonyM wrote: > > Your welcome > > So on 5.1.20 > <$list filter="[] ~[[false]]" variable=case> ><$list filter="[match[false]]" variable=case> > Do this if no case value > ><$list filter="[match[caseone]]"

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-03 Thread @TiddlyTweeter
Ciao TonyM I sat a bit with this and your last post that lists useful requests I've noted. I think the issue, at root, is "regex" is an powerful pattern matching "language" built into JavaScript that TW has access to. And its wortrh noting that a lot of TiddlyWiki, behind the scenes, uses it

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-01 Thread TonyM
And With *2019-08-01* give *20190801* (remove delimiters or return 2019 08 01 Do the reverse? add "-" tt position 4 6 8 Regards Tony On Friday, 2 August 2019 08:04:18 UTC+10, TonyM wrote: > > Josiah, > > I am busy at the moment but I am sure I can brainstorm some cases for > regex. > >

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-01 Thread TonyM
Josiah, I am busy at the moment but I am sure I can brainstorm some cases for regex. Does defining a macro containing the regex then using regexp resolve the use of "[ ]"? Off the top of my head - The equal test (already) - The Not equal test if there is one - Searching for common

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-01 Thread Mohammad
Yes that is true! Using SnR when I want to rename tiddlers like tid01/example01 to tid01\example01 or change a filter [tag[mytag]] to [tag] I encounter problem. By the way, finding a string ended by say *myword *or contains a special format like *date *or *number *are among cases we cannot use

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-01 Thread @TiddlyTweeter
An issue in TW in filters with regex is that "[" "]" are needed too in regex for "character classes" (e.g. [a-f, A-G]) to get them to work requires a bit more than normal regex since you can't use square brackets directly in TW regex filters, otherwise its works as expected. A few things like

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-01 Thread @TiddlyTweeter
I like regular expressions a lot. I'm not clear what people need though. The kind of thing I do with them I doubt most poeople would be interested in. I'll think about it. Maybe what is needed is an overview of the use of regex in TW (which is much wider actually than operators)? I think

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-01 Thread Mohammad
Josiah, I would also appreciate if you could provide examples of common and regexp in TW! You favored me and provided a help page for SnR in Tiddler Commander! I know regexp is very powerful but in tiddlywiki.com there is little documentation on that! You can have a daily post like *An Example

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-01 Thread @TiddlyTweeter
TonyM wrote: > > > I would not underestimate the value of a plain English operator like match > for easy to read tests especially when they control visibility and > structure in code. > Don't disagree. But its not a straw man. Its the intelligent man--when you need her. Your example triumphed

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-01 Thread TonyM
Josiah I would not underestimate the value of a plain English operator like match for easy to read tests especially when they control visibility and structure in code. On regex you could give the community A great resource if you provide 10 to 20 top regex tests we may want to use. I could

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-01 Thread @TiddlyTweeter
> > Now we would say > [regexp[^caseone$]] The difference here is that ^ is the marker for "start of string" and $ "end of string", regex meta characters. But there would be no difference between [regexp[caseone]] and [match[caseone]] So you are not really comparing equal cases. It

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-08-01 Thread @TiddlyTweeter
An aside in this thread.., but not irrelevant. Mat: I barely even know regexp badly. That is basically the only one I > know for exctly the reason of being able to make an exact comparison. BUT > don't take my word for it, I just found it on the web.. Regex is one of few areas of computing

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-31 Thread TonyM
Your welcome So on 5.1.20 <$list filter="[] ~[[false]]" variable=case> <$list filter="[match[false]]" variable=case> Do this if no case value <$list filter="[match[caseone]]" variable=case> Process "caseone" <$list filter="[match[casetwo]]" variable=case>

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-31 Thread Mohammad
Thanks Tony! This is great for code readability! Cheers Mohammad On Wednesday, July 31, 2019 at 5:46:25 PM UTC+4:30, TonyM wrote: > > Folks, > > Ad a result of Jeremy adding a new match operator to 5.1.20 the case > statements in this code pattern will be even more user friendly. > > First we

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-31 Thread TonyM
Folks, Ad a result of Jeremy adding a new match operator to 5.1.20 the case statements in this code pattern will be even more user friendly. First we would say [prefix[caseone]suffix[caseone]] Now we would say [regexp[^caseone$]] But this Will become which is easier to remember

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-27 Thread TonyM
Mat - thanks for your Idea never the less By the way prefix[one]suffix[one]] Is the closes to exact match we have. I expect onesomethingone will bypass this. regexp[^one$] is thus very helpful So the case can MAY now look like this but I expect the :: needs to be removed and "false" not a

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-27 Thread Mat
On Sunday, July 28, 2019 at 2:11:39 AM UTC+2, TonyM wrote: > > Mat, > > I expect it would suffice. I assume that is an equivalent for equal or > prefix[one]suffixe[one]]? > AFAIK it is used for exact match so it is not equivalent to prefix-suffix. > If you know regex well I could generate a

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-27 Thread TonyM
Mat, I expect it would suffice. I assume that is an equivalent for equal or prefix[one]suffixe[one]]? There is a bit of a barrier to all users using regexp. What would be nice is if some of the common ones like you demonstrated were documented for general users to use. Especially for the

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-27 Thread Mat
Interesting pattern. should be useful. If we ever get an equals[] operator this would become > [<__x__>equals[one]] > Not real yet :) > Would regexp[^one$] suffice? <:-) -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-27 Thread Mohammad
On Saturday, July 27, 2019 at 2:20:34 PM UTC+4:30, TonyM wrote: > > Mohammad, > > Yes the single prefix statement allows oneWord where "one" is the prefix > of another "word"! > > And to do what you say more literally you could use "contains[one]" > > This of course can be stopped if required

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-27 Thread TonyM
Mohammad, Yes the single prefix statement allows oneWord where "one" is the prefix of another "word"! And to do what you say more literally you could use "contains[one]" This of course can be stopped if required with filter="[<__x__>prefix[one]suffix[one]]" If we ever get an equals[]

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-27 Thread Mohammad
Thanks Tony! It works great! I also used a simple version as this \define case(x) <$list filter="[<__x__>prefix[one]]"> This is case one. <$list filter="[<__x__>prefix[two]]"> This is case two <$list filter="[<__x__>prefix[three]] [<__x__>prefix[four]]"> This is case three and four \end <>

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-27 Thread TonyM
Mohammad, I some ways I built this so the empty message did not require a macro, to keep all the logic in the one block. I would imaging people would copy such a block as follows <$list filter="[] ~[[::false]]" variable=case> <$list filter="[prefix[::false]]" variable=case> Do this

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-26 Thread Mohammad
Hi Tony! This is great and needs some examples to explore the pros and cons! By the way as you said the application may vary case by case and a macro may not be a good option. --Mohammad On Saturday, July 27, 2019 at 4:18:31 AM UTC+4:30, TonyM wrote: > > Mohammad, > > >> We need to wrap

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-26 Thread A Gloom
yes!! more!! I'll be srudying this... -- 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

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-26 Thread TonyM
Mohammad, > We need to wrap inside a macro to present a construct like > > <> > >> >> > In someways I am suggesting you do not need to make a "select-case macro " because the whole case structure including the empty case can be written inside the one outer list object. Thus it may be

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-26 Thread TonyM
Mohamad, I have rewritten the code pattern to suit your "else" use case > I use a lot $list as > > if *filter**-not-**empty* do-this *else* do-that > > >- filter is not empty do what is given inside $list widget >- filter is empty go for emptyMessage > > <$list filter="[]

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-26 Thread Mohammad
Hi Tony This is interesting! Could you give some simple examples? We need to wrap inside a macro to present a construct like <> What do you think? I use a lot $list as if *filter**-not-**empty* do-this *else* do-that - filter is not empty do what is given inside $list widget -

[tw5] Re: Interesting Code Patterns? Handling the emptyMessage condition in the ListWidget Body, a CASE structure, complex formulas

2019-07-25 Thread TonyM
Post Script the above is not tested. On Friday, July 26, 2019 at 2:20:31 PM UTC+10, TonyM wrote: > > I just wanted to share this code pattern I just discovered for Handling > the emptyMessage condition in the ListWidget Body. > > Sometimes the way we write Filters the only way to proceed is to