It is currently April 28th, 2024, 2:42 pm

[Bug] Negative Values in Variables and Measures

Report bugs with the Rainmeter application and suggest features.
User avatar
MerlinTheRed
Rainmeter Sage
Posts: 889
Joined: September 6th, 2011, 6:34 am

[Bug] Negative Values in Variables and Measures

Post by MerlinTheRed »

I noticed that you can run into problems when using Measures or Variables with negative values in Formulas. For example if I try this:

Code: Select all

[Variables]
Number=-1

[MeasureNegative]
Measure=Calc
Formula=-3

[MeasureCalculateSomething]
Measure=Calc
Formula=5+#Number#+[MeasureNegative]
DynamicVariables=1
Rainmeter complains about extra operations in the formula (syntax error) because what the Formula evaluator gets is: 5+-1+-3
what it should get is: 5+(-1)+(-3)
If I enclose all the variables and measure values in brackets, everything works fine, but in my opinion, this should not be necessary.
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
User avatar
AlC
Posts: 329
Joined: June 9th, 2011, 6:46 pm

Re: [Bug] Negative Values in Variables and Measures

Post by AlC »

Yes had the same problem today.

The exact words are:
Calc: #Extra operation! in measure [TestMeasure].
Rainmeter - You are only limited by your imagination and creativity.
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: [Bug] Negative Values in Variables and Measures

Post by poiru »

Use

Code: Select all

Formula=5+(#Number#)+[MeasureNegative]
for correct evaluation.
User avatar
MerlinTheRed
Rainmeter Sage
Posts: 889
Joined: September 6th, 2011, 6:34 am

Re: [Bug] Negative Values in Variables and Measures

Post by MerlinTheRed »

I already found that out (see my first post). I just think that this shouldn't be necessary in a proper formula evaluator.
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: [Bug] Negative Values in Variables and Measures

Post by Kaelri »

I have to disagree, actually. Variables work by direct string substitution: Rainmeter replaces the #Variable# name with the literal string value, then interprets the line as if the variable was never there. We can't treat variables like algebraic symbols because they aren't guaranteed to resolve to a number. Only another measure will always give you a number value, and you can reference measures directly, without dynamic variables:

Code: Select all

Formula=5+(#Number#)+MeasureNegative
If variables in Calc formulas were treated as a special case, we would lose the flexibility that direct substitution gives us. For example, you couldn't use them to stitch different parts of a formula together unless each part could be resolved independently.