Page 1 of 1

[Bug?] Using R inside of a conditional operation doesn't resolve

Posted: December 16th, 2017, 9:42 pm
by raiguard
I'm not sure if this is already known, but using relative positioning inside of a conditional operation doesn't work. It works if you use R after the conditional operation, but not inside.

For example, I was trying to use Y=((#hideDiskA# = 0) ? (#rowSpacing# + 2)R : #contentMargin#). This doesn't work and throws an error, saying Formula: "R" is unknown: ((1=0) ? (1 + 2)R : (5 + 3)). However, if I do something like Y=((#hideDiskA# = 0) ? (#rowSpacing# + 2) : #contentMargin#)R, it resolves and works perfectly, but doesn't work for my needs.

If this could be fixed it would make my life significantly easier. ;)

Re: [Bug?] Using R inside of a conditional operation doesn't resolve

Posted: December 16th, 2017, 10:14 pm
by balala
raiguard wrote:If this could be fixed it would make my life significantly easier. ;)
No, it probably can't be, because those conditional operations must be entirely numeric, strings are not allowed. Not even the r or R, used for relative positioning. Sorry...

Re: [Bug?] Using R inside of a conditional operation doesn't resolve

Posted: December 16th, 2017, 10:44 pm
by raiguard
Aw dang. Is this an intentional choice or is it a consequence of the design? I completely understand not having actual strings, but r or R should be usable.

I guess I could just use a section variable to do it instead.

Re: [Bug?] Using R inside of a conditional operation doesn't resolve

Posted: December 16th, 2017, 11:36 pm
by jsmorley
raiguard wrote:Aw dang. Is this an intentional choice or is it a consequence of the design? I completely understand not having actual strings, but r or R should be usable.

I guess I could just use a section variable to do it instead.
It's not so much that it is intentional, but that a ternary operation is a standard C language construct, and it is by its nature a purely numeric mathematical function. We have no intention of re-writing the entire C language math library from scratch, any more than we intend to re-write the entire Windows API library from scratch.

The documentation for Formulas in Rainmeter is pretty clear about what is allowed and what isn't in a mathematical formula.
Note: While [Measures], [SectionVariables:] and #Variables# can be used in a formula, all the components of a formula must be numeric, using only numbers, operators, functions and constants. Using .5 or .25 in a formula will cause an error. It must be 0.5 or 0.25.
You can use "R" or "r" in the X or Y option of a meter that uses a formula, as long as the "R" or "r" modifiers are outside the formula.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
Var1=5
Var2=6

[MeterOne]
Meter=String
X=0
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Hello

[MeterTwo]
Meter=String
X=(#Var2# > #Var1# ? 20 : 10)R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=World

Re: [Bug?] Using R inside of a conditional operation doesn't resolve

Posted: December 17th, 2017, 10:51 am
by balala
raiguard wrote:However, if I do something like Y=((#hideDiskA# = 0) ? (#rowSpacing# + 2) : #contentMargin#)R, it resolves and works perfectly, but doesn't work for my needs.
Please post your code, maybe we can find a solution.

Re: [Bug?] Using R inside of a conditional operation doesn't resolve

Posted: December 17th, 2017, 3:53 pm
by raiguard
balala wrote:Please post your code, maybe we can find a solution.
It’s 6000 lines long, so here’s the file on GitHub: https://github.com/raiguard/ModernGadgets/blob/master/Skins/ModernGadgets/Disks/Disks.ini

I’m in the middle of some major refactoring so it’s kinda broken at the moment.

However, I did figure out how to do it with section variables, so it’s good now anyway. Thanks for the help.

Re: [Bug?] Using R inside of a conditional operation doesn't resolve

Posted: December 17th, 2017, 4:20 pm
by balala
raiguard wrote:However, I did figure out how to do it with section variables, so it’s good now anyway. Thanks for the help.
And this means you don't need further help about your question any more?

Re: [Bug?] Using R inside of a conditional operation doesn't resolve

Posted: December 17th, 2017, 4:44 pm
by raiguard
balala wrote:And this means you don't need further help about your question any more?
Nope. Since jsmorley said it couldn’t be fixed, I found another way. Thanks.

Re: [Bug?] Using R inside of a conditional operation doesn't resolve

Posted: December 17th, 2017, 4:46 pm
by jsmorley
raiguard wrote:Nope. Since jsmorley said it couldn’t be fixed, I found another way. Thanks.
Great. There is nothing to "fix". It works exactly as it should.