Author Topic: Problems with > & < If/Then on numerical tags  (Read 139 times)

MayorQwert

  • Jr. Member
  • **
  • Posts: 51
I've noticed this problem for a while. It seems to have something to do with when the number of digits mismatch, though I'm not exactly sure. I did a test with $len(<title>)>30 as the logic. I notice when the number of digits match up the logic works, but when the $len(<title>) is a single digit or 3 digits it breaks.
It seems the issue is that the > and < functions are only looking at the first digit of the number?

So it will say things like:
1 < 30 but
5 < 30 because 5 is greater than 3
conversely,
99 > 30 but
102 < 30 because 1 is less than 3

Please ignore everything after here, I kept it here because there is still an issue with some of the cases I mention and I want to keep it noted so later discussion might make more sense.

I mainly just want to focus on the case I added to the start, however.


However, when you start to use functions it completely breaks.

I've had numerous times where I've tried to do functions where I take an element and trim it down for use in functions like this. For example, taking the length and cutting the seconds off so I just get the minute field, like if something is 5:35 and I trim it to 5, sometimes the function will break and display T/F in incorrect cases.

Another example is when I try to use > or < logic with the $len() command, similar results occur where it will occasionally defy the expected logic.

The most recent example was using the "Additional Tagging & Reporting Tools" where I utilize the Random function. I have to clip some elements off with the function because the first two and last character are not related to the actual random value output (It adds D# to the start and a 5 to the end, for some reason). I trim these off to just print the number I want, which can be between 1 and 1000.

I intended to use this with some < or > functions but the logic breaks at seemingly random intervals. For example, the 710 500 example from earlier.

If the random value is 710 resulting in 710 > 500, it will return an "F" value. It honestly seems even more arbitrary than that. When I ran the preview I saw a whole host of random values printed and the responses sometimes aligned and sometimes didn't. I even saw a case where there were two cases of "550" on the random number tag's output and one said "T" and the other said "F"!

For reference, here's the entirety of my code:
<Random1000> = $CutRight($CutLeft($Random(1000),2),1)
I need to cut because otherwise it would print D3<number>5
Random1000 has been set to "number" in the tag(2) properties

Test Function:
$If(<Random1000>>500,T,F)

Likewise, the same function but for a max value of 10 (same everything but take two 0s off all the functions
Testing a bunch of values yielded the following outputs (For Random10 > 5):

I've placed X's next to all the incorrect logic printouts.
T 9 > 5
F 9 > 5 X
T 5 > 5 X
T 7 > 5
F 9 > 5 X
F 8 > 5 X
F 6 > 5 X
F 7 > 5 X
F 7 > 5 X
F 5 > 5
F 1 > 5
F 0 > 5
T 6 > 5
T 0 > 5 X
F 0 > 5
F 0 > 5
F 6 > 5 X
T 9 > 5
F 6 > 5 X
F 6 > 5 X

I've had this problem in other cases as well, it seems to occur when any functions start to get involved from what I've seen? Not sure but it's a real headache!
Last Edit: February 16, 2021, 03:42:36 PM by MayorQwert

MayorQwert

  • Jr. Member
  • **
  • Posts: 51
I'm having the same issue with the "=" operator. I thought maybe if I am dealing with a single digit value then just simply saying "A = B" would not have trouble, but I have cases where it's claiming that 7=3, 7=1, 5=4, and that 10 is equal to 0, 1 and 3 at once. :\

It just makes no sense.

The Incredible Boom Boom

  • Sr. Member
  • ****
  • Posts: 402
Yes, performing numerical operations with MusicBee is quite challenging, though I don't remember having problems with single or same digit numbers. The first thing you'll have to do is to get things semi-consistent is make sure you're using $Pad() to compare numbers with.

MayorQwert

  • Jr. Member
  • **
  • Posts: 51
Yes, performing numerical operations with MusicBee is quite challenging, though I don't remember having problems with single or same digit numbers. The first thing you'll have to do is to get things semi-consistent is make sure you're using $Pad() to compare numbers with.
I was able to isolate the specific problem with the $Random function, it's a function error where it is refreshing every time it is called even if you have an external virtual tag for its output. It's refreshing so frequently that even the preview is misleading. The value it says it is outputting on the preview window is not the same value that is giving you the outputted value, for example. So I think that the logic is at least working with smaller values like it should on the MB side of things though I do still have all the other aforementioned issues with < or > that I have experienced before. I'll go ahead and edit the bit out about Random, though.

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 31865
I've noticed this problem for a while. It seems to have something to do with when the number of digits mismatch, though I'm not exactly sure. I did a test with $len(<title>)>30 as the logic. I notice when the number of digits match up the logic works, but when the $len(<title>) is a single digit or 3 digits it breaks.
It seems the issue is that the > and < functions are only looking at the first digit of the number?
that should be fixed now - the same applies to the count(), sum(), min(), max() functions which were processing the comparison as a string

https://getmusicbee.com/patches/MusicBee34_Patched.zip