Any good way to see if one version is higher than another?

71 views
Skip to first unread message

Mat

unread,
Jul 2, 2019, 1:13:22 PM7/2/19
to TiddlyWiki
Say I have two plugins A and B.

How can I - in a filter - evaluate if A's version value is greater than B's?
There is, to kill off your first idea, no "greaterthan" filter operator.

I don't want to do an action to set some value for calculation, i.e it is ideally only a filter evaluation.

Thanx

<:-)

Mark S.

unread,
Jul 2, 2019, 2:20:18 PM7/2/19
to TiddlyWiki
I can see how you can do it with two filter loops, and a slight cheat. Maybe two cheats.

The first cheat is that for most revisions, only the last part of the dotted notation is significant (e.g. 5.1.20 -- only the last dotted number has change for the last 4 (?) years).

The 2nd cheat is that you need TW 5.1.20prerelease, because it has a new split operator.

So you could have an outer filter with three runs. The first run finds the revision number or the first plugin and splits it by the period (.) and then uses the nth operator to find the 3rd rev portion. Repeat for the 2nd plugin. Then use the numerical sort operator and take the last tiddler, which will be the largest rev number. Put that number in a variable.

Then for the 2nd, inner filter, use the regexp operator with the variable to find the plugin with a matching rev number in the 3rd dotted notation position.

Tweak as necessary. For instance, the variable from list #1 may need to be modified by a macro in order to make it ready for the regular expression.


HTH

Mat

unread,
Jul 2, 2019, 3:06:58 PM7/2/19
to tiddl...@googlegroups.com
Thank you Mark.

The problem is that it has to be general enough to compare any two versions of a plugin not only the core. And it is not sure that the plugins follow the x.y.z format. 

Waiting until 5.1.20 is not a problem though. 

But I'm thinking that the core has a built in version comparison mechanism used in import. Is it possible to tap into this perhaps?

<:-)

Jeremy Ruston

unread,
Jul 3, 2019, 1:24:05 PM7/3/19
to tiddl...@googlegroups.com
Hi Mat


On 2 Jul 2019, at 20:06, Mat <matia...@gmail.com> wrote:

But I'm thinking that the core has a built in version comparison mechanism used in import. Is it possible to tap into this perhaps?

The core does indeed have a function to compare “major.minor.revision” format version numbers:


So, yes, we could expose it as a filter operator. Perhaps it should be done as part of a broader effort to add comparison operators.

Best wishes

Jeremy

Mat

unread,
Jul 3, 2019, 1:59:03 PM7/3/19
to TiddlyWiki
Jeremy Ruston wrote:
So, yes, we could expose it as a filter operator. Perhaps it should be done as part of a broader effort to add comparison operators.

That, including comparison ops, would be most excellent! 

Should I put up an issue?

<:-)
Reply all
Reply to author
Forward
0 new messages