• Status Unconfirmed
  • Percent Complete
  • Task Type Bugs
  • Category User Interface → Themes
  • Assigned To No-one
  • Operating System All players
  • Severity Low
  • Priority Very Low
  • Reported Version Release 3.12
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: Rockbox
Opened by gcocatre - 2013-08-22

FS#12891 - %?if() evaluates enumeration indexes and arbitrary numbers to (number + 1)

When displaying %mp in a theme while playback is stopped, the value 0 (zero) is displayed.

However, to test for “playback stopped”, one has to test:
%?if(%mp, =, 1)
That is, one has to test for (index + 1) in order to return true for any given enumerator index number.

Same problem when testing for an arbitrary number. Example:
%?if(%ss(0, 2, %St(font), number), =, 15)
returns true when the font is set to “14-Nimbus”, and false when the font is set to “15-Adobe-Helvetica”.

When testing a %tag that holds a numerical value though, it works as expected:
%?if(%pv, =, 0)
returns true when volume is set to 0dB.

Fixing this would likely break all existing Rockbox themes. One solution to this, would be to require new / updated themes to include some specific code that “acknowledges” the new behavior.

Another possible solution:

Now: Endorse current if() behaviour by documenting it
Soon: Add a ifV2() that works as expected
Then: Declare if() to be deprecated

The problem is that the value (the one you get via %if) is used for conditionals too. A value of 0 in conditionals selects the false branch, which always the most right one. We do not want this for enumerations, where the first value should be the most left one. For this reason 0 changes to 1, 1 to 2, and so on. I understand that this is inconsistent with the value printed. FWIW, I think few (if any) people print the value of %mp, it's always used as conditional to display bitmaps.

Your second example surprises me a lot, though.


Available keyboard shortcuts


Task Details

Task Editing