It is currently March 29th, 2024, 9:27 am

Cannot substitute numeric values

Report bugs with the Rainmeter application and suggest features.
kati42
Posts: 35
Joined: May 4th, 2009, 4:25 am

Cannot substitute numeric values

Post by kati42 »

I have a measure that detects registry values. These values are long alphanumeric strings. I have a calc measure that then tests the value and has certain ifabove, ifequal and ifbelow behavior.

Code: Select all

[MeasurePowerScheme]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=SYSTEM\ControlSet001\Control\Power\User\PowerSchemes
RegValue=ActivePowerScheme
Substitute="381b4222-f694-41f0-9685-ff5bb260df2e":"2","8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c":"3","a1841308-3541-4fab-bc81-f71556f20b4a":"1"

; Could substitute above with name of image file and just have one meter
; But I want the icon to be a button that cycles through the schemes, and buttons don't
; have a measure. So I need to control showing/hiding different meters manually
[MeasurePowerSchemeCalc]
Measure=Calc
Formula=MeasurePowerScheme

[MeterPS]
MeasureName=MeasurePowerScheme
Meter=STRING
X=25
Y=0
FontFace=#TextFont#
FontSize=10
FontColor=#TextColor#

[MeterPS2]
MeasureName=MeasurePowerSchemeCalc
Meter=STRING
X=50
Y=0
FontFace=#TextFont#
FontSize=10
FontColor=#TextColor#
The problem is that these two meters do not display the same value. If my power scheme is balanced, the registry value read by the MeasurePowerScheme is substituted with a 2, which is displayed by MeterPS. MeterPS2, on the other hand, displays 0.

I suspect it is because MeasurePowerScheme is a string datatype, and therefore cannot be treated as a numeric value. Perhaps this is more of a feature request, but I would like the substitute capability to include substituting with numeric values.

This may seem like a weird example, but that is because I have simplified it. What I am really trying to do is use a more complex MeasurePowerSchemeCalc that uses IfEqual IfAbove and IfBelow statements to show/hide buttons that cycle through the power schemes. I can't just use the substitute to choose a file name like the weather skin because I need it to have different mouse button behavior depending on which scheme it is (I want the button to cycle through the schemes).

If this is not fixed, I can side-step the problem by creating an additional "pop-up" config to select the power scheme, but I would really prefer to just make the image that indicates the scheme also be a button to cycle through them.

Thanks...
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: Cannot substitute numeric values

Post by dragonmage »

I may have a better workaround for you...
Make a button image that is all but transparent overlayed on top of your icon, you could even do a slight highlight for mouseover and slight darkening for pressed, then use your command for changing schemes as the ButtonCommand.
kati42
Posts: 35
Joined: May 4th, 2009, 4:25 am

Re: Cannot substitute numeric values

Post by kati42 »

That may work. It'd still be good to get the bug/feature fixed, though. But I'll probably use that solution in the meantime.
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: Cannot substitute numeric values

Post by dragonmage »

Where in your code are you trying to use the IFs?
kati42
Posts: 35
Joined: May 4th, 2009, 4:25 am

Re: Cannot substitute numeric values

Post by kati42 »

dragonmage wrote:Where in your code are you trying to use the IFs?
Inside of MeasurePowerSchemeCalc. That measure has as its formula just MeasurePowerScheme (as shown in the code above). But the two are not equal (unless MeasurePowerScheme is 0). So that's the real problem, not the IFs.
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: Cannot substitute numeric values

Post by dragonmage »

Just wondering, instead of using the calc measure can you just use a duplicate of the PowerSchemeMeasure without the substitutions. Will the actual alpha-numeric strings work as your If values?
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: Cannot substitute numeric values

Post by dragonmage »

Hey, I was wondering if you had tried my last idea.
kati42
Posts: 35
Joined: May 4th, 2009, 4:25 am

Re: Cannot substitute numeric values

Post by kati42 »

It does not work. I believe the IfEqualValue has to be a number. Using a formula to directly compare the string value also does not work, because I believe the values in the formula must also be numbers.

(sorry - have been busy)
kati42
Posts: 35
Joined: May 4th, 2009, 4:25 am

Re: Cannot substitute numeric values

Post by kati42 »

Oh, and I realized why the first suggestion does not work either; the command to change the power scheme depends on what the current power scheme is (since I want a "cycle through" behavior)...