It is currently May 6th, 2024, 3:51 am

Calc and IfBelowValue/IfBelowAction

Get help with creating, editing & fixing problems with skins
zerosp4c3
Posts: 2
Joined: January 21st, 2012, 1:01 am

Calc and IfBelowValue/IfBelowAction

Post by zerosp4c3 »

Wondering if someone can fill me in on what's going on here. I'm using a variable NumDisks to change stuff in this test skin, and this code works successfully if it's 2 or more. However, if I uncomment the IfBelow lines, that action is always run regardless of the value of NumDisks.

Code: Select all

[Variables]
NumDisks=2
PostfixChar=2

[MeasureNumDisks]
Measure=CALC
Formula=#NumDisks#
;IfBelowValue=2
;IfBelowAction=!Execute [!WriteKeyValue Variables PostfixChar "1"][!DisableMeasure MeasureNumDisks]
IfEqualValue=2
IfEqualAction=!Execute [!WriteKeyValue Variables PostfixChar "2"][!DisableMeasure MeasureNumDisks]
IfAboveValue=2
IfAboveAction=!Execute [!WriteKeyValue Variables PostfixChar "3"][!DisableMeasure MeasureNumDisks]
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Calc and IfBelowValue/IfBelowAction

Post by smurfier »

That would be because until the first update the value of the measure is 0 and the action is fired.

[cCounter]
Measure=calc
Formula=cCounter+1
IfAboveValue=3
IfAboveAction=!ToggleMeasureGroup ms
Group=ms

Now add Group=ms and Disabled=1 to your other measure and you should be good to go.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
zerosp4c3
Posts: 2
Joined: January 21st, 2012, 1:01 am

Re: Calc and IfBelowValue/IfBelowAction

Post by zerosp4c3 »

Thanks a ton, I had no idea and was getting frustrated.

Edit:
I got it to work with the code you provided, but wasn't able to get it to work until I took out the DisableMeasures.

I have no idea how to refresh the skin to reflect that the variable has been changed either.

Is it possible that this method of checking 3 states of a variable that can be set via another skin is just a bad idea?

Edit 2:
I was having a lot of trouble with the unexpected results from writing that variable. Decided I can code things just as neatly without the IfBelow, thanks!
User avatar
Brian
Developer
Posts: 2689
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Calc and IfBelowValue/IfBelowAction

Post by Brian »

zerosp4c3 wrote:I have no idea how to refresh the skin to reflect that the variable has been changed either.
Check out !Refresh from the manual.
zerosp4c3 wrote:Is it possible that this method of checking 3 states of a variable that can be set via another skin is just a bad idea?
It's not a bad idea, however it can be tricky to get the results you want while waiting for an update to happen.
zerosp4c3 wrote:I was having a lot of trouble with the unexpected results from writing that variable. Decided I can code things just as neatly without the IfBelow, thanks!
This is what's cool with Rainmeter. It's nice that there can be a more than one solution to a problem.

Good luck with your coding. :)

-Brian