Compare operator usage

56 views
Skip to first unread message

PS

unread,
May 24, 2020, 10:34:57 AM5/24/20
to TiddlyWiki
I'm trying to learn how to use the math operators in TW and having some issues. 

{{{ [[40]divide[4]] }}}


That works.

{{{ [[4]match[4]] }}}


And that works....

{{{ [[4]compare:number:eq[4]] }}}


That doesn't? I don't understand.... The documentation even says these operators are synonymous. I can't get any of the examples for the compare operator to return anything.

This is what I want to use the compare operator in, to return a certain number of items by using a field I've called sequence:

<ol>
<$list filter="[tag
<currentTiddler>[get[sequence]]compare:number:lteq[3]]">
<li></li>
</$list>
</ol>

Mark S.

unread,
May 24, 2020, 11:31:30 AM5/24/20
to TiddlyWiki
Which browser including vsn. are you using?

Mark S.

unread,
May 24, 2020, 12:14:32 PM5/24/20
to TiddlyWiki
Also, which version of TiddlyWiki ?

PS

unread,
May 24, 2020, 12:44:26 PM5/24/20
to TiddlyWiki
Ahh.... Thanks, Mark. So I was using an outdated version of TW, and with 5.1.22, the documentation examples and the 4=4 example work for the compare operator! That makes sense; couldn't figure out how I was doing it wrong. So those are in working order, now.

I do seem to be using the operator incorrectly in my filter example with the 'sequence' field, though. It just returns the beginning of a list "1." and nothing else.

As for browser, I use both Chrome (83.0.4103.61), and Tiddly Desktop. I do know the latter is out of date (0.0.13) because I'm confused at how to update it and not just install again.

Mark S.

unread,
May 24, 2020, 1:46:18 PM5/24/20
to TiddlyWiki


On Sunday, May 24, 2020 at 9:44:26 AM UTC-7, PS wrote:
Ahh.... Thanks, Mark. So I was using an outdated version of TW, and with 5.1.22, the documentation examples and the 4=4 example work for the compare operator! That makes sense; couldn't figure out how I was doing it wrong. So those are in working order, now.


Your sequence list filter is kind of wrong. Your probably want something like:

<$list filter="[tag<currentTiddler>get[sequence]compare:number:lteq[3]]" variable="num">

However this will always return a series of numbers, probably 0 to 3.

To get the matching tiddlers, you will probably need to add a "variable" as above,  and create a nested inner list widget, like:

<$list filter="[tag<currentTiddler>sequence<num>]">
<li><<currentTiddler>></li>
</$list>


As for browser, I use both Chrome (83.0.4103.61), and Tiddly Desktop. I do know the latter is out of date (0.0.13) because I'm confused at how to update it and not just install again.

I suspect there's a subtle bug in the latest Chrome and Tiddly Desktop in respect to TW. Perhaps Jeremy will be able to comment when he comes back. In the mean time, there's no reason to upgrade to 0.0.14 unless you need one of the new features. When you do upgrade, it's pretty much as easy as unzipping the files and running the new executable.


PS

unread,
May 24, 2020, 2:52:56 PM5/24/20
to TiddlyWiki
Awesome, I was able to adapt this perfectly! Thanks very much. I'm still cobbling together a lot of my understanding of TW and learning on the fly (as the documentation gets very confusing without any computer science background), which means I get a lot of things slightly wrong.

So, if I understand correctly, what this is doing is the first filter creates the variable "num" and looks in the sequence field of those tagged tiddlers for all values less than or equal to 3, and stores those in "num". And then the second filter, my guess is, looks at the tagged tiddlers which have a value matching the values stored in "num" and returns those? Is that close to what's going on?

Oh, that's all that needs to be done to update? I wasn't sure if stuff like TW file locations could carry over.

Mark S.

unread,
May 24, 2020, 3:09:30 PM5/24/20
to TiddlyWiki


On Sunday, May 24, 2020 at 11:52:56 AM UTC-7, PS wrote:
Awesome, I was able to adapt this perfectly! Thanks very much. I'm still cobbling together a lot of my understanding of TW and learning on the fly (as the documentation gets very confusing without any computer science background), which means I get a lot of things slightly wrong.

So, if I understand correctly, what this is doing is the first filter creates the variable "num" and looks in the sequence field of those tagged tiddlers for all values less than or equal to 3, and stores those in "num". And then the second filter, my guess is, looks at the tagged tiddlers which have a value matching the values stored in "num" and returns those? Is that close to what's going on?


Yeah. It sounds like you got it. If that "compare" operator had a field parameter, then you could do it with just one list widget. Oh well.
 
Oh, that's all that needs to be done to update? I wasn't sure if stuff like TW file locations could carry over.


I *think* so, but I could be remembering wrong. But since it's just a matter of dragging and dropping files into the TD console, it's no big deal even if it doesn't remember the prior settings.
Reply all
Reply to author
Forward
0 new messages