It is currently March 28th, 2024, 11:13 am

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

Report bugs with the Rainmeter application and suggest features.
Post Reply
User avatar
raiguard
Posts: 660
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA
Contact:

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

Post 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. ;)
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

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

Post 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...
User avatar
raiguard
Posts: 660
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA
Contact:

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

Post 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.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

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

Post 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
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

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

Post 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.
User avatar
raiguard
Posts: 660
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA
Contact:

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

Post 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.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

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

Post 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?
User avatar
raiguard
Posts: 660
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA
Contact:

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

Post 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.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

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

Post 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.
Post Reply