Rockbox Technical Forums

Support and General Use => Theming and Appearance Customization => Topic started by: sockbox on April 12, 2012, 06:28:04 PM

Title: %if, %and, %or not working for me
Post by: sockbox on April 12, 2012, 06:28:04 PM
I'm not sure if I'm using the conditional tags wrong so I wanted to ask here before filing a bug.

I'm trying to use multiple %if  conditionals in an %and and %or statement but it only works if the conditional is using the %mp tag. It never works when I add more than one %bl or %pv conditional.

Below, all the commented lines do not work.

Code: [Select]
%?and(%if(%mp,>,1),%if(%mp,<,3))<hello>
%?and(%if(%mp,>,0),%if(%bl,<,100))<dog>
%?or(%if(%mp,=,1),%if(%mp,=,2))<play>

#%?and(%if(%bl,<=,100),%if(%bl,>,90))<%bl>
#%?and(%if(%pv,<,100),%if(%bl,<,90))<%bl>
#%?and(%if(%mp,=,1),%if(%bl,<,90),%if(%pv,<,80))<cat>
#%?or(%if(%pv,<,100),%if(%bl,<,90))<%bl>
Title: Re: %if, %and, %or not working for me
Post by: sockbox on April 15, 2012, 03:24:21 AM
It turns out that the inequality symbols require % signs in front. Thanks to kiwicam  and his Alien theme for the workaround.

Code: [Select]
%?and(%if(%pv,%<,100),%if(%bl,%<,90))<%bl>
%?and(%if(%mp,%>,1),%if(%bl,%<,90),%if(%pv,%<,80))<cat>
%?or(%if(%pv,%<,100),%if(%bl,%<,90))<%bl>
%?and(%if(%bl,%>,50),%if(%bl,%<,90),%if(%pv,%<,80))<cat>
Title: Re: %if, %and, %or not working for me
Post by: KiwiCam on April 15, 2012, 04:58:17 AM
Works like a treat. I'm pretty sure that credit goes to JdGordon  :-* for that solution.

That's some pretty interesting code you've got going on there. I gave up on trying to use %and & %or, and that's probably where I was getting caught out myself. But now you've got me thinking about what I can do with those.

That's one thing I love about this theme-ing malarkey. I see what others are doing and I get inspired.

Title: Re: %if, %and, %or not working for me
Post by: JdGordon on April 16, 2012, 12:49:36 AM
Damn, OK I thought I fixed this problem.

What happens is the parser is a bit stupid and it sees < without realising it cant possibly be a conditional list so errors out. I fixed it to work for when %if() is by itself, but didnt realise it fails when it it nested.
I'm going to try fixing this today/soon, but yeah, put %'s in front untill it is fixed.
Title: Re: %if, %and, %or not working for me
Post by: JdGordon on April 16, 2012, 01:44:49 AM
http://gerrit.rockbox.org/214 fixes this issue but needs to be tested properly before I'll commit it.
Title: Re: %if, %and, %or not working for me
Post by: KiwiCam on May 21, 2012, 03:01:08 AM
I apologise. I'm not sure what else I'm required to do for testing it, as as far as I'm aware, I think it works. I don't know what else to do. I wasn't really certain about what I had to do, to do this for you, in the first place. I thought I knew.

So, I'm sorry, I'd really love to help, but you'll either have to take me through what I need to do from the beginning step by step, or tell me where, or what, it is that I need to do, from where I left off, so that you've got your confirmation.

Then hopefully, I can also provide some future help. So, please.

Title: Re: %if, %and, %or not working for me
Post by: JdGordon on May 21, 2012, 03:26:51 AM
That patch is merged already... does the origional wps code still not work?
Title: Re: %if, %and, %or not working for me
Post by: KiwiCam on May 21, 2012, 04:48:27 AM
That patch is merged already... does the origional wps code still not work?

You mean with the %? As I understand it, I have two Sansa's with that patch installed from my builds. My themes work with both the % and no %, with that patched build. ie, both ways of coding work. Is that what you were expecting? It's been  since then that I've done anything with Rockbox, so I'm rusty again.