It is currently April 27th, 2024, 3:42 pm

If Statements

Get help with creating, editing & fixing problems with skins
WezzLee
Posts: 35
Joined: June 11th, 2012, 5:29 pm

If Statements

Post by WezzLee »

Hi, I am having problems figuring out the If statement measures.
All I need is a measure that will check a variable and then depending execute a bunch of bangs.
[Tab3VariableCheck]
Measure=IfAction
IfEqualValue=1
IfAboveAction=!execute [!ShowMeter MeterSteamTab][!HideMeter MeterOriginTab][!

RainmeterRedraw]
IfEqualValue=2
IfAboveAction=!execute [!ShowMeter MeterOriginTab][!HideMeter MeterSteamTab][!

RainmeterRedraw]
This is what I have, however the guide doesn't say what to define the Measure as, or says where you indicate what variable to use. I was thinking that the Measure might be equal to the variable, and that could be how you show which variable you want to check, but it didn't work.
Any help would be great thanks.
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: If Statements

Post by Kaelri »

There are a few misconceptions going on here:
  1. "IfAction" is not a measure by itself. IfActions are options that can be added to other measures.
  2. An "Action" is always paired with a "Value." IfAboveAction and IfAboveValue, IfEqualAction and IfEqualValue, etc.
Here's an example of a working measure with an IfAction. This measure would set a warning message when your CPU usage crosses above 90%, and a different message if it crosses below 10%.

Code: Select all

[MeasureCPU]
Measure=CPU
IfAboveValue=90
IfAboveAction=!SetVariable "WarningMessage" "Your CPU usage is very high."
IfBelowValue=10
IfBelowAction=!SetVariable "WarningMessage" "Your CPU usage is very low."
WezzLee
Posts: 35
Joined: June 11th, 2012, 5:29 pm

Re: If Statements

Post by WezzLee »

Do I have to call it Measure=CPU? Since my measure has nothing to do with CPU I didn't think it was right.

Also how does the if statement know which variable it is checking?
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: If Statements

Post by poiru »

WezzLee wrote:Also how does the if statement know which variable it is checking?
The IfAction are used with existing measures. They will compare the specified value with the measure's value. In Kaelri's example, the IfActions are checking against the value of the CPU measure.

If you don't understand, post your entire skin and tell us exactly what you want to do.
WezzLee
Posts: 35
Joined: June 11th, 2012, 5:29 pm

Re: If Statements

Post by WezzLee »

I won't post the entire thing because its something like 1500 lines, but here is what you need;
[Variables] - The variables I need the if statements to check.
Tab2=2
Tab3=1
Tab4=2
Tab6=1
[Tab2VariableCheck] - I have 4 of these, each checking a different variable and changing meters depending on which variable used. This Measure uses Tab2
Measure=CPU
IfEqualValue=1
IfAboveAction=!execute [!ShowMeter MeterIETab][!HideMeter MeterChromeTab][!HideMeter MeterFirefoxTab][!RainmeterRedraw]
IfEqualValue=2
IfAboveAction=!execute [!ShowMeter MeterChromeTab][!HideMeter MeterIETab][!HideMeter MeterFirefoxTab][!RainmeterRedraw]
IfEqualValue=3
IfAboveAction=!execute [!ShowMeter MeterFireFoxTab][!HideMeter MeterIETab][!HideMeter MeterChromeTab][!RainmeterRedraw]
All I need is the measures to change the display of 4 different meters depending on 4 different variables.

ps. In-case there is a problem or something, here is one of the meters changing one of the variables;
[Change3Steam]
Meter=String
MeterStyle=ChangeText
Text=Steam
X=701
Y=60
Hidden=1
LeftMouseUpAction=!execute [!ShowMeter MeterSteamTab][!HideMeter MeterOriginTab][!ToggleMeter Change3Steam][!ToggleMeter Change3Origin][!SetVariable Tab3 1][!RainmeterRedraw]
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: If Statements

Post by Kaelri »

Again, the "CPU" measure that I used was just an example. IfActions can be applied to any measure. The IfValue is compared to the value of the measure.

In this case, all you need is a Calc measure to check the variable. Something like this:

Code: Select all

[Tab2VariableCheck]
Measure=Calc
Formula=#Tab2#
DynamicVariables=1
IfEqualValue=1
IfAboveAction=!execute [!ShowMeter MeterIETab][!HideMeter MeterChromeTab][!HideMeter MeterFirefoxTab][!RainmeterRedraw]
IfEqualValue=2
IfAboveAction=!execute [!ShowMeter MeterChromeTab][!HideMeter MeterIETab][!HideMeter MeterFirefoxTab][!RainmeterRedraw]
IfEqualValue=3
IfAboveAction=!execute [!ShowMeter MeterFireFoxTab][!HideMeter MeterIETab][!HideMeter MeterChromeTab][!RainmeterRedraw]
WezzLee
Posts: 35
Joined: June 11th, 2012, 5:29 pm

Re: If Statements

Post by WezzLee »

Okay, Well no more errors when I refresh the skin, thank god, but it still doesn't seem to check the variable with what you said. Lets say; 1 = IE, 2 = Chrome, 3 = Firefox. I have Tab2=3 at the moment, however when I refresh the skin IE will show instead. Just wondering why?
Tab2=3
[Tab2VariableCheck]
Measure=Calc
Formula=#Tab2#
DynamicVariables=1
IfEqualValue=1
IfAboveAction=!execute [!ShowMeter MeterIETab][!HideMeter MeterChromeTab][!HideMeter MeterFirefoxTab][!RainmeterRedraw]
IfEqualValue=2
IfAboveAction=!execute [!ShowMeter MeterChromeTab][!HideMeter MeterIETab][!HideMeter MeterFirefoxTab][!RainmeterRedraw]
IfEqualValue=3
IfAboveAction=!execute [!ShowMeter MeterFireFoxTab][!HideMeter MeterIETab][!HideMeter MeterChromeTab][!RainmeterRedraw]
User avatar
MerlinTheRed
Rainmeter Sage
Posts: 889
Joined: September 6th, 2011, 6:34 am

Re: If Statements

Post by MerlinTheRed »

Kaelri wrote:Again, the "CPU" measure that I used was just an example. IfActions can be applied to any measure. The IfValue is compared to the value of the measure.

In this case, all you need is a Calc measure to check the variable. Something like this:

Code: Select all

[Tab2VariableCheck]
Measure=Calc
Formula=#Tab2#
DynamicVariables=1
IfEqualValue=1
IfAboveAction=!execute [!ShowMeter MeterIETab][!HideMeter MeterChromeTab][!HideMeter MeterFirefoxTab][!RainmeterRedraw]
IfEqualValue=2
IfAboveAction=!execute [!ShowMeter MeterChromeTab][!HideMeter MeterIETab][!HideMeter MeterFirefoxTab][!RainmeterRedraw]
IfEqualValue=3
IfAboveAction=!execute [!ShowMeter MeterFireFoxTab][!HideMeter MeterIETab][!HideMeter MeterChromeTab][!RainmeterRedraw]
This seems wrong. You have multiple IfEqualValues and multiple IfAboveActions. Shouldn't it at least be IfEqualActions? And are multiple IfEqualActions supported? I thought there can only be one of each kind on a measure. See here: http://rainmeter.net/cms/Measures-IfActions
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: If Statements

Post by Kaelri »

Yes, that's correct. I was sloppy with my copy & paste. Apologies.

Corrected version:

Code: Select all

[Tab2VariableCheck]
Measure=Calc
Formula=#Tab2#
DynamicVariables=1
IfBelowValue=2
IfBelowAction=!execute [!ShowMeter MeterIETab][!HideMeter MeterChromeTab][!HideMeter MeterFirefoxTab][!RainmeterRedraw]
IfEqualValue=2
IfEqualAction=!execute [!ShowMeter MeterChromeTab][!HideMeter MeterIETab][!HideMeter MeterFirefoxTab][!RainmeterRedraw]
IfAboveValue=2
IfAboveAction=!execute [!ShowMeter MeterFireFoxTab][!HideMeter MeterIETab][!HideMeter MeterChromeTab][!RainmeterRedraw]
(That was really embarrassing...)
WezzLee
Posts: 35
Joined: June 11th, 2012, 5:29 pm

Re: If Statements

Post by WezzLee »

I have one that has 1 to 4, what do I do when there is 4?
IfBelowValue=2
IfBelowAction=!execute [!ShowMeter MeterSkypeTab][!HideMeter MeterMumbleTab][!HideMeter MeterVentriloTab][!HideMeter MeterTeamspeakTab][!RainmeterRedraw]
IfEqualValue=2
IfEqualAction=!execute [!ShowMeter MeterMumbleTab][!HideMeter MeterSkypeTab][!HideMeter MeterVentriloTab][!HideMeter MeterTeamspeakTab][!RainmeterRedraw]
IfAboveValue=2
IfAboveAction=!execute [!ShowMeter MeterVentriloTab][!HideMeter MeterMumbleTab][!HideMeter MeterSkypeTab][!HideMeter MeterTeamspeakTab][!RainmeterRedraw]
If???Value=4
If???Action=!execute [!ShowMeter MeterTeamspeakTab][!HideMeter MeterMumbleTab][!HideMeter MeterVentriloTab][!HideMeter MeterSkypeTab][!RainmeterRedraw]
Also the variables aren't changing.

I'm using [!SetVariable Tab2 "2"] is this right?