Uploaded image for project: 'Picard'
  1. Picard
  2. PICARD-2257

Math, trim, replace functions not working with extracted numbers from strings

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • None
    • 2.6.3
    • None
    • win 10

      Have been trying to use the acoustic brainz high level data to calc some variables and for some reason many functions doesn't work as expected once a 2 digit number is retrieved from them

      I'm using the latest plugin version 2.2 which fixed scripting, so I think this is another bug. (see https://tickets.metabrainz.org/browse/PICARD-2256)

      For ex: (where %ab:hi:mood_happy:happy% is something like 0.044545..) (see image 1)

      $noop(Valence tags: Valence -number-)
      $set(_tempA,%ab:hi:mood_happy:happy%)
      $set(_tempB,$get(ab:hi:mood_sad:not sad))
      $if($eq($substr(%_tempA%,2,3),0),$set(_tempA,‎‎$substr(%_tempA%,3,4)),$set(_tempA,‎‎$substr(%_tempA%,2,4)))
      $if($eq($substr(%_tempB%,2,3),0),$set(_tempB,‎‎$substr(%_tempB%,3,4)),$set(_tempB,‎‎$substr(%_tempB%,2,4)))
      $set(valenceA,%_tempA%)
      $set(valenceB,%_tempB%)
      $set(valenceC,‎%valenceA%‎ - %valenceB%)
      $set(valenceD,‎$add(%valenceA%,%valenceB%))

      ValenceD returns nothing, instead of summing the values. Note the other values are right and present (see image 2).

      Using num returns nothing too.. (see image 3) although clearly valenceA is an existing number.

      $set(valenceE,‎$num(%valenceA%,0))

      Note I had to use first $substr() to check if TempA or TempB had a 0 because using $trim(,0) or regexp didn't work once I extracted the 2 digits (like many other text functions). In other words:

      $trim(04,0) -> 4
      $trim(%tempA%,0) -> where %tempA% is 04 -> 04
      

      It's like the 2 digits extracted string is not recognized neither as a string nor as an integer number... thus rendering incorrect input for all text/number functions when using the variable.

       

        1. image1.JPG
          image1.JPG
          40 kB
        2. image2.JPG
          image2.JPG
          24 kB
        3. image3.JPG
          image3.JPG
          23 kB

            Unassigned Unassigned
            Isabelxxx Isabelxxx
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Version Package