It is currently April 27th, 2024, 12:34 am

Adding integers seemingly produces a string

Get help with creating, editing & fixing problems with skins
jn_meter
Posts: 136
Joined: December 27th, 2016, 12:04 pm

Adding integers seemingly produces a string

Post by jn_meter »

Hello (again)!

I have:

Code: Select all

updateDivider_disc_usedOrFree=8
updateDivider_disc_usedOrFree_systemDisc_no_increment=1

updateDivider_disc_usedOrFree_systemDisc_yes=#updateDivider_disc_usedOrFree#
updateDivider_disc_usedOrFree_systemDisc_no=#updateDivider_disc_usedOrFree_systemDisc_yes# + #updateDivider_disc_usedOrFree_systemDisc_no_increment#
But the log shows:

Image

Note the '8+1'!
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Adding integers seemingly produces a string

Post by ikarus1969 »

It all seems ok. Even the '8 + 1' as you noted. All the variables are just text substitutions as long as they are not used in a calculation or CALC measure.

So i don't want to guess what you mean. What's your specific question?
jn_meter
Posts: 136
Joined: December 27th, 2016, 12:04 pm

Re: Adding integers seemingly produces a string

Post by jn_meter »

I was presuming that because the '8+1' was a string it would not work when used as an update divider. My intended question was, How do I circumvent that?

I did not actually really test that the variable was not working as an update divider. However, I did notice that some measures, which involved it, failed (at least sometimes) to update when I thought they would.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Adding integers seemingly produces a string

Post by jsmorley »

jn_meter wrote: January 18th, 2021, 12:55 pm I was presuming that because the '8+1' was a string it would not work when used as an update divider. My intended question was, How do I circumvent that?

I did not actually really test that the variable was not working as an update divider. However, I did notice that some measures, which involved it, failed (at least sometimes) to update when I thought they would.
It will work as an UpdateDivider, but be sure you have identified it as a (formula) where you use it.

Code: Select all

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

[Variables]
Upd=5+10

[MeasureCalc]
Measure=Calc
Formula=Counter
UpdateDivider=(#Upd#)

[MeterOne]
Meter=String
MeasureName=MeasureCalc
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Or conversely...

Code: Select all

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

[Variables]
Upd=(5+10)

[MeasureCalc]
Measure=Calc
Formula=Counter
UpdateDivider=#Upd#

[MeterOne]
Meter=String
MeasureName=MeasureCalc
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
jn_meter
Posts: 136
Joined: December 27th, 2016, 12:04 pm

Re: Adding integers seemingly produces a string

Post by jn_meter »

Thank you very much for that detailed explanation. Here we uncover - must work around - a limitation of Rainmeter, it seems.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Adding integers seemingly produces a string

Post by jsmorley »

jn_meter wrote: January 18th, 2021, 1:28 pm Thank you very much for that detailed explanation. Here we uncover - must work around - a limitation of Rainmeter, it seems.
I don't really see it as a limitation. It's just a fact that really every option value in Rainmeter is a "string". Things that are numbers are converted from a string to an actual number when and where you "use them" as a number, in any option that supports a number. In the case of something like:

Code: Select all

[Variables]
Size=11

[MeterString]
Meter=String
FontSize=#Size#
The String meter won't have any issue, as it is looking for a number as the value, and "11" is a perfectly valid number. It happily converts the string "11" to a number.

In the case of:

Code: Select all

[Variables]
Size=10 + 1

[MeterString]
Meter=String
FontSize=(#Size#)
The string "10 + 1" is NOT a "number". It is a "formula". So we have to enclose it in (parentheses) in order to alert Rainmeter that we want to use the string as a (formula). It then knows to send the string off to a "math" routine that will evaluate and resolve the formula. That math routine will then return a number, 11 in this case, that the option will use.

There are a few places where a formula is "assumed", and the parentheses are optional, like the Formula option in a Calc measure, and the test in an IfCondition option, but pretty much everywhere else, you will always need to enclose any formula in parentheses.

https://docs.rainmeter.net/manual/formulas/


There are also a few places, like the Text option on a String meter or the String option on a String measure as examples, that simply do not use numbers or formulas, and are always treated as a literal string. These are options that are simply never "numeric". This is necessary so you can in fact display a formula as a string without it somehow automatically resolving it to a final number. Like Text=The formula is (10 + 1) for this .

Code: Select all

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

[Variables]
Upd=(10 + 1)

[MeasureResolveFormula]
Measure=Calc
Formula=#Upd#

[MeterOne]
Meter=String
MeasureName=MeasureResolveFormula
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=The formula is #Upd# for this, which resolves to %1

1.jpg
You do not have the required permissions to view the files attached to this post.