Rockbox

Tasklist

FS#11516 - new skin tag... %if() allows you to have more control over conditionals

Attached to Project: Rockbox
Opened by Jonathan Gordon (jdgordon) - Tuesday, 03 August 2010, 12:39 GMT
Last edited by Jonathan Gordon (jdgordon) - Thursday, 19 August 2010, 13:55 GMT
Task Type Patches
Category Themes
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Release 3.6
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

This patch adds a new tag which lets you have more control over conditionals.
%if( <tag>, <operator>, <value> [, num_options] ) ....
tag is a different token which you want to use (i.e %mp)
operator is any of: (without the quotes) "eq" for equality, "neq" for not equality, "lt" for less than. "lte" for less than or equal, "gt" for greater than" and "gte" for great than or equal. (If people would prefer I'm happy to change these to ==, !=, <, <=, >, >= )
value is the value to compare against.
num_options is an optional value to give to the tag to say how many options it "has" (some tags scale the value to the number of conditional options, i.e %pv)

OK, so how would you use this tag? Lets say you want to do a small animation when fast forwarding...
%?if( %mp, eq, 4)<%t(0.1)%xd(Aa);%t(0.1)%xd(Ab);%t(0.1)%xd(Ac);%t(0.1)%xd(Ad)>
and the opposite animation for rewind...
%?if( %mp, eq, 5)<%t(0.1)%xd(Ad);%t(0.1)%xd(Ac);%t(0.1)%xd(Ab);%t(0.1)%xd(Aa)>


Compare that to:
%t(0.1)%?mp<|||%xd(Aa)|%xd(Ae)>;%t(0.1)%?mp<|||%xd(Ab)|%xd(Ad)>;%t(0.1)%?mp<|||%xd(Ac)|%xd(Ac)>;%t(0.1)%?mp<|||%xd(Ad)|%xd(Ab)>;%t(0.1)%?mp<|||%xd(Ae)|%xd(Aa)>;%t(0.1)%?mp<|||%xd(Af)|%xd(Ah)>;%t(0.1)%?mp<|||%xd(Ag)|%xd(Ag)>;%t(0.1)%?mp<|||%xd(Ah)|%xd(Af)>
This task depends upon

Closed by  Jonathan Gordon (jdgordon)
Thursday, 19 August 2010, 13:55 GMT
Reason for closing:  Accepted
Comment by Frank Gevaerts (fg) - Tuesday, 03 August 2010, 12:47 GMT
Would this only work for numeric tags?

I wouldn't mind seeing this in a slightly more general way, where value could also be a tag, and where string tags can be used. That would allow things like showing the next album/artist *only* if they're different from the current one, which is something I've wanted to do a few times.
Comment by Jonathan Gordon (jdgordon) - Tuesday, 03 August 2010, 12:50 GMT
right now it is only numeric, and text tags are treated as 1 if there is text and 0 if not.
I was thinking that adding string comparisons would be fairly trivial. tag compare is slightly harder because the parser doesnt (yet) let you specify either a tag or a number param. but fixing that shuldnt be too hard.
Comment by Rosso Maltese (asettico) - Wednesday, 04 August 2010, 07:52 GMT
To maintain some similitude with other programming languages, I suggest to avoid the three letter operator. So:
NEQ -> NE
LTE -> LE
GTE -> GE

But, after all, ye old symbols are preferable... :-)
Comment by Jonathan Gordon (jdgordon) - Wednesday, 04 August 2010, 08:00 GMT
I'm hoping to do string and tag comparisson tonight so maybe I'll just use the actual symbols (and I'll use the numeric string sorting code so < and > for strings work.)

I wonder if there is any point adding a "between" operator also. I'm not sure it would ever be used but I thought %if( %if( %pv, gte, -10), eq, %if(%pv, lte, 10)) might be a bit hard to read? :D

Loading...