It is currently April 25th, 2024, 4:41 pm

[BUG?] Substitute not yielding result on first update

Report bugs with the Rainmeter application and suggest features.
User avatar
Yincognito
Rainmeter Sage
Posts: 7164
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [BUG?] Substitute not yielding result on first update

Post by Yincognito »

Brian wrote: November 13th, 2021, 8:07 pm Another alternative is to just use the section variable in the meter altogether.

Code: Select all

[Variables]
Calc=1.6

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

---Measures---

[MeasureCalc]
Measure=Calc
Formula=#Calc#

---Meters---

[MeterCalc]
Meter=String
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
Text="Number = [MeasureCalc:]#CRLF#Rounded = [MeasureCalc:0]"
DynamicVariables=1
-Brian
Indeed, you're perfectly right. This is actually the solution I was using before, except that I need to perform an additional adjustment of the result, and this can only be done in a measure and not a meter. A simple example is the numerical 359.6 angle, that I need to transform into "0" and not "360", since all my computations and displaying are based on integer angles between "0" and "359" (that fit well with the % operator, aka modulo) and don't produce side effects. In other words, my (obsolete, by now) substitution in the measure looked like:

Code: Select all

RegExpSubstitute=1
Substitute="^.*$":"[#CURRENTSECTION#:0]","360":"0"
so the thing is that while I can use the equivalent of the 1st substitution in the meter like you showed, I can't use an equivalent of the 2nd. In the end, either truncation to the lower value (a bit inconvenient for obvious reasons) or something like:

Code: Select all

[Variables]
Calc=359.6

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!UpdateMeasure "MeasureCalc"]

---Measures---

[MeasureCalc]
Measure=Calc
Formula=(#Calc#)
UpdateDivider=-1
OnUpdateAction=[!SetVariable CalcRound ([MeasureCalc]>359?0:[MeasureCalc:0])]
DynamicVariables=1

---Meters---

[MeterCalc]
Meter=String
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
Text="Calc = #CalcRound#"
DynamicVariables=1
would probably do. I would have avoided duplicating values (either through new variables or measures) though, it seems such a waste. Too bad "an ideal solution" doesn't look like it's possible for my case here. Will see what solution I'll eventually choose - at least there are some that look feasible, so thank you for the ideas, they were quite helpful. :thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth